diff options
Diffstat (limited to 'src/commands/dev')
-rw-r--r-- | src/commands/dev/eval.ts | 8 | ||||
-rw-r--r-- | src/commands/dev/reload.ts | 2 | ||||
-rw-r--r-- | src/commands/dev/say.ts | 2 | ||||
-rw-r--r-- | src/commands/dev/setLevel.ts | 7 | ||||
-rw-r--r-- | src/commands/dev/sh.ts | 4 | ||||
-rw-r--r-- | src/commands/dev/superUser.ts | 2 | ||||
-rw-r--r-- | src/commands/dev/test.ts | 14 |
7 files changed, 21 insertions, 18 deletions
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 5b44db2..10360cf 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -70,7 +70,7 @@ export default class EvalCommand extends BushCommand { } args.code = args.code.replace(/[“”]/g, '"').replace(/```*(?:js|ts)?/g, ''); - const code = { + const code: { ts: string | null; js: string; lang: 'ts' | 'js' } = { ts: args.typescript ? args.code : null, js: args.typescript ? transpile(args.code) : args.code, lang: args.typescript ? 'ts' : 'js' @@ -79,7 +79,7 @@ export default class EvalCommand extends BushCommand { const embed = new _MessageEmbed(); const badPhrases = ['delete', 'destroy']; - if (badPhrases.some((p) => code[code.lang].includes(p)) && !args.sudo) { + if (badPhrases.some((p) => code[code.lang]!.includes(p)) && !args.sudo) { return await message.util.send(`${util.emojis.error} This eval was blocked by smooth brain protection™.`); } @@ -119,7 +119,7 @@ export default class EvalCommand extends BushCommand { const inputJS = await util.inspectCleanRedactCodeblock(code.js, 'js'); const inputTS = code.lang === 'ts' ? await util.inspectCleanRedactCodeblock(code.ts, 'ts') : undefined; try { - const rawOutput = code[code.lang].replace(/ /g, '').includes('9+10' || '10+9') ? '21' : await eval(code.js); + const rawOutput = code[code.lang]!.replace(/ /g, '').includes('9+10' || '10+9') ? '21' : await eval(code.js); const output = await util.inspectCleanRedactCodeblock(rawOutput, 'js', { depth: args.sel_depth ?? 0, showHidden: args.hidden, @@ -148,7 +148,7 @@ export default class EvalCommand extends BushCommand { embed.addField('📤 Output', await util.inspectCleanRedactCodeblock(e?.stack || e, 'js')); } - embed.setTimestamp().setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true })); + embed.setTimestamp().setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true }) ?? undefined); if (!args.silent || message.util.isSlash) { await message.util.reply({ embeds: [embed] }); diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index 4f11a81..91cabfb 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -44,7 +44,7 @@ export default class ReloadCommand extends BushCommand { client.inhibitorHandler.reloadAll(); return message.util.send(`🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`); } catch (e) { - if (output) void client.logger.error('reloadCommand', output); + if (output!) void client.logger.error('reloadCommand', output); return message.util.send(`An error occurred while reloading:\n${await util.codeblock(e?.stack || e, 2048 - 34, 'js')}`); } } diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts index f0a7cbf..1c797ea 100644 --- a/src/commands/dev/say.ts +++ b/src/commands/dev/say.ts @@ -42,6 +42,6 @@ export default class SayCommand extends BushCommand { }); } await message.interaction.reply({ content: 'Attempting to send message.', ephemeral: true }); - return message.channel.send({ content, allowedMentions: AllowedMentions.none() }); + return message.channel!.send({ content, allowedMentions: AllowedMentions.none() }); } } diff --git a/src/commands/dev/setLevel.ts b/src/commands/dev/setLevel.ts index 97527fa..e69b9df 100644 --- a/src/commands/dev/setLevel.ts +++ b/src/commands/dev/setLevel.ts @@ -44,7 +44,8 @@ export default class SetLevelCommand extends BushCommand { } ], ownerOnly: true, - slash: true + slash: true, + channel: 'guild' }); } @@ -58,11 +59,11 @@ export default class SetLevelCommand extends BushCommand { const [levelEntry] = await Level.findOrBuild({ where: { user: user.id, - guild: message.guild.id + guild: message.guild!.id }, defaults: { user: user.id, - guild: message.guild.id + guild: message.guild!.id } }); await levelEntry.update({ xp: Level.convertLevelToXp(level) }); diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index 7f048c0..025a308 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -5,7 +5,7 @@ import { MessageEmbed, Util } from 'discord.js'; import { promisify } from 'util'; const sh = promisify(exec); -const clean = (text) => { +const clean = (text: string | any) => { chalk.toString; if (typeof text === 'string') { return (text = Util.cleanCodeBlockContent(text)); @@ -43,7 +43,7 @@ export default class ShCommand extends BushCommand { const embed = new MessageEmbed() .setColor(util.colors.gray) - .setFooter(message.author.tag, message.author.avatarURL({ dynamic: true })) + .setFooter(message.author.tag, message.author.avatarURL({ dynamic: true }) ?? undefined) .setTimestamp() .setTitle('Shell Command') .addField('📥 Input', await util.codeblock(input, 1024, 'sh')) diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 5178684..957e2b7 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -49,7 +49,7 @@ export default class SuperUserCommand extends BushCommand { `${util.emojis.error} I fucked up here is args ${await util.inspectCleanRedactCodeblock(args, 'ts')}` ); - const superUsers = (await Global.findByPk(client.config.environment)).superUsers; + const superUsers: string[] = (await Global.findByPk(client.config.environment))?.superUsers ?? []; let success; if (args.action === 'add') { if (superUsers.includes(args.user.id)) { diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index 60e93c4..151e4a1 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -56,9 +56,9 @@ export default class TestCommand extends BushCommand { const embed = new MessageEmbed() .addField('Field Name', 'Field Content') .setAuthor('Author', 'https://www.w3schools.com/w3css/img_snowtops.jpg', 'https://google.com/') - .setColor(message.member.displayColor) + .setColor(message.member?.displayColor ?? util.colors.default) .setDescription('Description') - .setFooter('Footer', message.author.avatarURL()) + .setFooter('Footer', message.author.avatarURL() ?? undefined) .setURL('https://duckduckgo.com/') .setTimestamp() .setImage('https://media.sproutsocial.com/uploads/2017/02/10x-featured-social-media-image-size.png') @@ -91,14 +91,15 @@ export default class TestCommand extends BushCommand { return await util.buttonPaginate(message, embeds); } else if (['lots of embeds'].includes(args?.feature?.toLowerCase())) { const description = 'This is a description.'; - const author = { name: 'This is a author', iconURL: message.author.avatarURL({ dynamic: true }) }; - const footer = { text: 'This is a footer', iconURL: message.author.avatarURL({ dynamic: true }) }; + const _avatar = message.author.avatarURL({ dynamic: true }) ?? undefined; + const author = { name: 'This is a author', iconURL: _avatar }; + const footer = { text: 'This is a footer', iconURL: _avatar }; const fields = []; for (let i = 0; i < 25; i++) { fields.push({ name: 'Field ' + i, value: 'Field Value ' + i }); } const c = util.colors; - const o = { description, author, footer, fields }; + const o = { description, author, footer, fields }!; const embeds = [ new MessageEmbed({ ...o, ...{ title: 'Embed Title 0', color: c.red } }).setTimestamp(), @@ -134,10 +135,11 @@ export default class TestCommand extends BushCommand { // }); // }) // ); + if (!message.guild) return await message.util.reply(`${util.emojis.error} This test can only be run in a guild.`); const guildCommands = await message.guild.commands.fetch(); // eslint-disable-next-line @typescript-eslint/no-misused-promises guildCommands.forEach(async (command) => await command.delete()); - const globalCommands = await client.application.commands.fetch(); + const globalCommands = await client.application!.commands.fetch(); // eslint-disable-next-line @typescript-eslint/no-misused-promises globalCommands.forEach(async (command) => await command.delete()); |