diff options
| author | Hellyson Rodrigo Parteka <[email protected]> | 2021-11-12 16:30:18 -0300 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2021-11-20 19:01:51 -0500 |
| commit | fe5f9cf9a7df3b9cc42d7165ca8566e36fa70039 (patch) | |
| tree | 347b72ce0e04898ce8732153af1f9ef8e7937f48 /src/commands | |
| parent | 1ddd19dbb97f77f51e30819a24cd839ace1f073e (diff) | |
| download | muse-fe5f9cf9a7df3b9cc42d7165ca8566e36fa70039.tar.xz muse-fe5f9cf9a7df3b9cc42d7165ca8566e36fa70039.zip | |
feat: discord.js v13
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/config.ts | 9 | ||||
| -rw-r--r-- | src/commands/help.ts | 12 | ||||
| -rw-r--r-- | src/commands/queue.ts | 2 | ||||
| -rw-r--r-- | src/commands/shortcuts.ts | 4 |
4 files changed, 16 insertions, 11 deletions
diff --git a/src/commands/config.ts b/src/commands/config.ts index 0e5728a..8f3e0aa 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -1,4 +1,4 @@ -import {TextChannel, Message, GuildChannel} from 'discord.js'; +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'; @@ -20,6 +20,7 @@ export default class implements Command { 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); @@ -35,7 +36,7 @@ export default class implements Command { return; } - if (msg.author.id !== msg.guild!.owner!.id) { + if (msg.author.id !== msg.guild!.ownerId) { await msg.channel.send(errorMsg('not authorized')); return; } @@ -51,7 +52,7 @@ export default class implements Command { } case 'channel': { - let channel: GuildChannel | undefined; + 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('>'))); @@ -59,7 +60,7 @@ export default class implements Command { channel = msg.guild!.channels.cache.find(c => c.name === args[1]); } - if (channel && channel.type === 'text') { + if (channel && channel.type === 'GUILD_TEXT') { await Settings.update({channel: channel.id}, {where: {guildId: msg.guild!.id}}); await Promise.all([ diff --git a/src/commands/help.ts b/src/commands/help.ts index f150c54..7058efd 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -1,4 +1,4 @@ -import {Message} from 'discord.js'; +import {Message, Util} from 'discord.js'; import {injectable} from 'inversify'; import Command from '.'; import {TYPES} from '../types.js'; @@ -29,7 +29,7 @@ export default class implements Command { const {prefix} = settings; - const res = this.commands.sort((a, b) => a.name.localeCompare(b.name)).reduce((content, command) => { + const res = Util.splitMessage(this.commands.sort((a, b) => a.name.localeCompare(b.name)).reduce((content, command) => { const aliases = command.aliases.reduce((str, alias, i) => { str += alias; @@ -53,9 +53,13 @@ export default class implements Command { content += '\n'; return content; - }, ''); + }, '')); + + for (const r of res) { + // eslint-disable-next-line no-await-in-loop + await msg.author.send(r); + } - await msg.author.send(res, {split: true}); await msg.react('🇩'); await msg.react('🇲'); } diff --git a/src/commands/queue.ts b/src/commands/queue.ts index 85420e8..1c0735c 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -74,7 +74,7 @@ export default class implements Command { embed.addField('Page', `${queuePage} out of ${maxQueuePage}`, false); - await msg.channel.send(embed); + await msg.channel.send({embeds: [embed]}); } else { await msg.channel.send('queue empty'); } diff --git a/src/commands/shortcuts.ts b/src/commands/shortcuts.ts index 109d5fc..929a5c1 100644 --- a/src/commands/shortcuts.ts +++ b/src/commands/shortcuts.ts @@ -55,7 +55,7 @@ export default class implements Command { const newShortcut = {shortcut: shortcutName, command, guildId: msg.guild!.id, authorId: msg.author.id}; if (shortcut) { - if (shortcut.authorId !== msg.author.id && msg.author.id !== msg.guild!.owner!.id) { + if (shortcut.authorId !== msg.author.id && msg.author.id !== msg.guild!.ownerId) { await msg.channel.send(errorMsg('you do\'nt have permission to do that')); return; } @@ -80,7 +80,7 @@ export default class implements Command { } // Check permissions - if (shortcut.authorId !== msg.author.id && msg.author.id !== msg.guild!.owner!.id) { + if (shortcut.authorId !== msg.author.id && msg.author.id !== msg.guild!.ownerId) { await msg.channel.send(errorMsg('you don\'t have permission to do that')); return; } |
