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 { - 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 { - 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 & Pick; + readonly slashCommand?: Partial & Pick; requiresVC?: boolean; executeFromInteraction?: (interaction: CommandInteraction) => Promise; } 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(TYPES.Services.NaturalLanguage).to(NaturalLangua // Commands [ Clear, - Config, Disconnect, ForwardSeek, Pause,