aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2021-12-13 20:51:08 -0500
committerMax Isom <[email protected]>2021-12-13 20:51:08 -0500
commitc33526b8b7825cbf01a9ca1c84ab3fd30a94ef0f (patch)
tree1fd73d5b290f0c60673509c1557a78049a03d7b1 /src
parentc5e4c4b5cf1c08d304eb6e41aac1615e7007ee6e (diff)
downloadmuse-c33526b8b7825cbf01a9ca1c84ab3fd30a94ef0f.tar.xz
muse-c33526b8b7825cbf01a9ca1c84ab3fd30a94ef0f.zip
Migrate disconnect command
Diffstat (limited to 'src')
-rw-r--r--src/commands/config.ts81
-rw-r--r--src/commands/disconnect.ts23
-rw-r--r--src/commands/index.ts2
-rw-r--r--src/inversify.config.ts2
4 files changed, 14 insertions, 94 deletions
diff --git a/src/commands/config.ts b/src/commands/config.ts
deleted file mode 100644
index 8f3e0aa..0000000
--- a/src/commands/config.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-import {TextChannel, Message, GuildChannel, ThreadChannel} from 'discord.js';
-import {injectable} from 'inversify';
-import {Settings} from '../models/index.js';
-import errorMsg from '../utils/error-msg.js';
-import Command from '.';
-
-@injectable()
-export default class implements Command {
- public name = 'config';
- public aliases = [];
- public examples = [
- ['config prefix !', 'set the prefix to !'],
- ['config channel music-commands', 'bind the bot to the music-commands channel'],
- ];
-
- public async execute(msg: Message, args: string []): Promise<void> {
- if (args.length === 0) {
- // Show current settings
- const settings = await Settings.findByPk(msg.guild!.id);
-
- if (settings) {
- let response = `prefix: \`${settings.prefix}\`\n`;
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
- response += `channel: ${msg.guild!.channels.cache.get(settings.channel)!.toString()}`;
-
- await msg.channel.send(response);
- }
-
- return;
- }
-
- const setting = args[0];
-
- if (args.length !== 2) {
- await msg.channel.send(errorMsg('incorrect number of arguments'));
- return;
- }
-
- if (msg.author.id !== msg.guild!.ownerId) {
- await msg.channel.send(errorMsg('not authorized'));
- return;
- }
-
- switch (setting) {
- case 'prefix': {
- const newPrefix = args[1];
-
- await Settings.update({prefix: newPrefix}, {where: {guildId: msg.guild!.id}});
-
- await msg.channel.send(`👍 prefix updated to \`${newPrefix}\``);
- break;
- }
-
- case 'channel': {
- let channel: GuildChannel | ThreadChannel | undefined;
-
- if (args[1].includes('<#') && args[1].includes('>')) {
- channel = msg.guild!.channels.cache.find(c => c.id === args[1].slice(2, args[1].indexOf('>')));
- } else {
- channel = msg.guild!.channels.cache.find(c => c.name === args[1]);
- }
-
- if (channel && channel.type === 'GUILD_TEXT') {
- await Settings.update({channel: channel.id}, {where: {guildId: msg.guild!.id}});
-
- await Promise.all([
- (channel as TextChannel).send('hey apparently I\'m bound to this channel now'),
- msg.react('👍'),
- ]);
- } else {
- await msg.channel.send(errorMsg('either that channel doesn\'t exist or you want me to become sentient and listen to a voice channel'));
- }
-
- break;
- }
-
- default:
- await msg.channel.send(errorMsg('I\'ve never met this setting in my life'));
- }
- }
-}
diff --git a/src/commands/disconnect.ts b/src/commands/disconnect.ts
index 89b0b85..d196985 100644
--- a/src/commands/disconnect.ts
+++ b/src/commands/disconnect.ts
@@ -1,4 +1,5 @@
-import {Message} from 'discord.js';
+import {CommandInteraction} from 'discord.js';
+import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
@@ -7,11 +8,9 @@ import Command from '.';
@injectable()
export default class implements Command {
- public name = 'disconnect';
- public aliases = ['dc'];
- public examples = [
- ['disconnect', 'pauses and disconnects player'],
- ];
+ public readonly slashCommand = new SlashCommandBuilder()
+ .setName('disconnect')
+ .setDescription('pauses and disconnects player');
public requiresVC = true;
@@ -21,16 +20,20 @@ export default class implements Command {
this.playerManager = playerManager;
}
- public async execute(msg: Message, _: string []): Promise<void> {
- const player = this.playerManager.get(msg.guild!.id);
+ public async executeFromInteraction(interaction: CommandInteraction) {
+ const player = this.playerManager.get(interaction.guild!.id);
if (!player.voiceConnection) {
- await msg.channel.send(errorMsg('not connected'));
+ await interaction.reply({
+ content: errorMsg('not connected'),
+ ephemeral: true,
+ });
+
return;
}
player.disconnect();
- await msg.channel.send('u betcha');
+ await interaction.reply('u betcha');
}
}
diff --git a/src/commands/index.ts b/src/commands/index.ts
index 981c1fb..91b76c5 100644
--- a/src/commands/index.ts
+++ b/src/commands/index.ts
@@ -6,7 +6,7 @@ export default interface Command {
name?: string;
aliases?: string[];
examples?: string[][];
- slashCommand?: Partial<SlashCommandBuilder> & Pick<SlashCommandBuilder, 'toJSON'>;
+ readonly slashCommand?: Partial<SlashCommandBuilder> & Pick<SlashCommandBuilder, 'toJSON'>;
requiresVC?: boolean;
executeFromInteraction?: (interaction: CommandInteraction) => Promise<void>;
}
diff --git a/src/inversify.config.ts b/src/inversify.config.ts
index 77ed99b..6272dd3 100644
--- a/src/inversify.config.ts
+++ b/src/inversify.config.ts
@@ -15,7 +15,6 @@ import NaturalLanguage from './services/natural-language-commands.js';
// Comands
import Command from './commands';
import Clear from './commands/clear.js';
-import Config from './commands/config.js';
import Disconnect from './commands/disconnect.js';
import ForwardSeek from './commands/fseek.js';
import Pause from './commands/pause.js';
@@ -55,7 +54,6 @@ container.bind<NaturalLanguage>(TYPES.Services.NaturalLanguage).to(NaturalLangua
// Commands
[
Clear,
- Config,
Disconnect,
ForwardSeek,
Pause,