diff options
Diffstat (limited to 'src/commands/dev')
-rw-r--r-- | src/commands/dev/dm.ts | 2 | ||||
-rw-r--r-- | src/commands/dev/eval.ts | 8 | ||||
-rw-r--r-- | src/commands/dev/javascript.ts | 7 | ||||
-rw-r--r-- | src/commands/dev/reload.ts | 27 | ||||
-rw-r--r-- | src/commands/dev/say.ts | 2 | ||||
-rw-r--r-- | src/commands/dev/servers.ts | 4 | ||||
-rw-r--r-- | src/commands/dev/sh.ts | 13 | ||||
-rw-r--r-- | src/commands/dev/superUser.ts | 15 | ||||
-rw-r--r-- | src/commands/dev/test.ts | 10 |
9 files changed, 36 insertions, 52 deletions
diff --git a/src/commands/dev/dm.ts b/src/commands/dev/dm.ts index f1e2bce..c1340b1 100644 --- a/src/commands/dev/dm.ts +++ b/src/commands/dev/dm.ts @@ -41,7 +41,7 @@ export default class DMCommand extends BushCommand { args: { user: ArgType<'user'>; content: ArgType<'string'> } ) { try { - await client.users.send(args.user.id, args.content); + await this.client.users.send(args.user.id, args.content); } catch (e) { return message.util.reply(`${emojis.error} There was an error sending ${format.input(args.user.tag)} a dm.`); } diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 239a06a..2be2963 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -11,7 +11,6 @@ import { getMethods, Global, Guild, - inspectCleanRedactCodeblock, Level, ModLog, Shared, @@ -243,10 +242,11 @@ export default class EvalCommand extends BushCommand { /* eslint-disable @typescript-eslint/no-unused-vars */ const me = message.member, member = message.member, - bot = client, + bot = this.client, + client = this.client, guild = message.guild, channel = message.channel, - config = client.config, + config = this.client.config, members = message.guild?.members, roles = message.guild?.roles; /* eslint-enable @typescript-eslint/no-unused-vars */ @@ -315,7 +315,7 @@ export default class EvalCommand extends BushCommand { options.depth ??= 1; options.getters ??= true; - return inspectCleanRedactCodeblock(obj, language, options); + return this.client.utils.inspectCleanRedactCodeblock(obj, language, options); } } diff --git a/src/commands/dev/javascript.ts b/src/commands/dev/javascript.ts index 7c47f2f..e472a5a 100644 --- a/src/commands/dev/javascript.ts +++ b/src/commands/dev/javascript.ts @@ -3,7 +3,6 @@ import { clientSendAndPermCheck, colors, emojis, - inspectCleanRedactCodeblock, type ArgType, type CommandMessage, type OptArgType, @@ -60,13 +59,13 @@ export default class JavascriptCommand extends BushCommand { } const code = args.code.replace(/[“”]/g, '"').replace(/```*(?:js)?/g, ''); const embed = new EmbedBuilder(); - const input = await inspectCleanRedactCodeblock(code, 'js'); + const input = await this.client.utils.inspectCleanRedactCodeblock(code, 'js'); try { const rawOutput = /^(9\s*?\+\s*?10)|(10\s*?\+\s*?9)$/.test(code) ? '21' : new VM({ eval: true, wasm: true, timeout: 1_000, fixAsync: true }).run(`${code}`); - const output = await inspectCleanRedactCodeblock(rawOutput, 'js', { + const output = await this.client.utils.inspectCleanRedactCodeblock(rawOutput, 'js', { depth: args.sel_depth ?? 0, getters: true, inspectStrings: true, @@ -82,7 +81,7 @@ export default class JavascriptCommand extends BushCommand { embed.setTitle(`${emojis.errorFull} Unable to Evaluate Expression`).setColor(colors.error); embed.addFields([ { name: '📥 Input', value: input }, - { name: '📤 Error', value: await inspectCleanRedactCodeblock(e, 'js', { colors: false }) } + { name: '📤 Error', value: await this.client.utils.inspectCleanRedactCodeblock(e, 'js', { colors: false }) } ]); } diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index 8c2000f..40d53eb 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -1,13 +1,4 @@ -import { - BushCommand, - clientSendAndPermCheck, - codeblock, - emojis, - formatError, - shell, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { BushCommand, clientSendAndPermCheck, emojis, formatError, shell, type CommandMessage, type SlashMessage } from '#lib'; export default class ReloadCommand extends BushCommand { public constructor() { @@ -44,17 +35,19 @@ export default class ReloadCommand extends BushCommand { const s = new Date(); output = await shell(`yarn build:${/* args.fast ? 'esbuild' : */ 'tsc'}`); await Promise.all([ - client.commandHandler.reloadAll(), - client.listenerHandler.reloadAll(), - client.inhibitorHandler.reloadAll(), - client.contextMenuCommandHandler.reloadAll(), - client.taskHandler.reloadAll() + this.client.commandHandler.reloadAll(), + this.client.listenerHandler.reloadAll(), + this.client.inhibitorHandler.reloadAll(), + this.client.contextMenuCommandHandler.reloadAll(), + this.client.taskHandler.reloadAll() ]); return message.util.send(`🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`); } catch (e) { - if (output!) void client.logger.error('reloadCommand', output); - return message.util.send(`An error occurred while reloading:\n${await codeblock(formatError(e), 2048 - 34, 'js', true)}`); + if (output!) void this.client.logger.error('reloadCommand', output); + return message.util.send( + `An error occurred while reloading:\n${await this.client.utils.codeblock(formatError(e), 2048 - 34, 'js', true)}` + ); } } } diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts index 6ec52a1..2246588 100644 --- a/src/commands/dev/say.ts +++ b/src/commands/dev/say.ts @@ -43,7 +43,7 @@ export default class SayCommand extends BushCommand { } public override async execSlash(message: SlashMessage, args: { content: string }) { - if (!client.config.owners.includes(message.author.id)) { + if (!this.client.config.owners.includes(message.author.id)) { return await message.interaction.reply({ content: `${emojis.error} Only my developers can run this command.`, ephemeral: true diff --git a/src/commands/dev/servers.ts b/src/commands/dev/servers.ts index 28a4e5d..ab66f1c 100644 --- a/src/commands/dev/servers.ts +++ b/src/commands/dev/servers.ts @@ -26,7 +26,7 @@ export default class ServersCommand extends BushCommand { } public override async exec(message: CommandMessage | SlashMessage) { - const guilds = [...client.guilds.cache.sort((a, b) => (a.memberCount < b.memberCount ? 1 : -1)).values()]; + const guilds = [...this.client.guilds.cache.sort((a, b) => (a.memberCount < b.memberCount ? 1 : -1)).values()]; const chunkedGuilds: Guild[][] = chunk(guilds, 10); const embeds: APIEmbed[] = chunkedGuilds.map((chunk) => { return { @@ -36,7 +36,7 @@ export default class ServersCommand extends BushCommand { name: format.input(guild.name), value: stripIndent` **ID:** ${guild.id} - **Owner:** ${client.users.cache.has(guild.ownerId) ? client.users.cache.get(guild.ownerId)!.tag : guild.ownerId} + **Owner:** ${this.client.users.cache.has(guild.ownerId) ? this.client.users.cache.get(guild.ownerId)!.tag : guild.ownerId} **Members:** ${guild.memberCount.toLocaleString()}` })) } as APIEmbed; diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index f7c17bd..7ffdf27 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -2,7 +2,6 @@ import { ArgType, BushCommand, clientSendAndPermCheck, - codeblock, colors, emojis, formatError, @@ -51,7 +50,7 @@ export default class ShCommand extends BushCommand { } public override async exec(message: CommandMessage | SlashMessage, args: { command: ArgType<'string'> }) { - if (!client.config.owners.includes(message.author.id)) + if (!this.client.config.owners.includes(message.author.id)) return await message.util.reply(`${emojis.error} Only my developers can run this command.`); const input = clean(args.command); @@ -61,7 +60,7 @@ export default class ShCommand extends BushCommand { .setTimestamp() .setTitle('Shell Command') .addFields([ - { name: '📥 Input', value: await codeblock(input, 1024, 'sh', true) }, + { name: '📥 Input', value: await this.client.utils.codeblock(input, 1024, 'sh', true) }, { name: 'Running', value: emojis.loading } ]); @@ -81,12 +80,14 @@ export default class ShCommand extends BushCommand { embed.setTitle(`${emojis.successFull} Executed command successfully.`).setColor(colors.success).spliceFields(1, 1); - if (stdout) embed.addFields([{ name: '📤 stdout', value: await codeblock(stdout, 1024, 'ansi', true) }]); - if (stderr) embed.addFields([{ name: '📤 stderr', value: await codeblock(stderr, 1024, 'ansi', true) }]); + if (stdout) embed.addFields([{ name: '📤 stdout', value: await this.client.utils.codeblock(stdout, 1024, 'ansi', true) }]); + if (stderr) embed.addFields([{ name: '📤 stderr', value: await this.client.utils.codeblock(stderr, 1024, 'ansi', true) }]); } catch (e) { embed.setTitle(`${emojis.errorFull} An error occurred while executing.`).setColor(colors.error).spliceFields(1, 1); - embed.addFields([{ name: '📤 Output', value: await codeblock(formatError(e, true), 1024, 'ansi', true) }]); + embed.addFields([ + { name: '📤 Output', value: await this.client.utils.codeblock(formatError(e, true), 1024, 'ansi', true) } + ]); } await message.util.edit({ embeds: [embed] }); } diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 3de04bf..24e8c9a 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -1,13 +1,4 @@ -import { - BushCommand, - clientSendAndPermCheck, - emojis, - format, - getShared, - insertOrRemoveFromShared, - type ArgType, - type CommandMessage -} from '#lib'; +import { BushCommand, clientSendAndPermCheck, emojis, format, type ArgType, type CommandMessage } from '#lib'; import { type ArgumentGeneratorReturn, type ArgumentTypeCasterReturn } from 'discord-akairo'; export default class SuperUserCommand extends BushCommand { @@ -65,14 +56,14 @@ export default class SuperUserCommand extends BushCommand { public override async exec(message: CommandMessage, args: { action: 'add' | 'remove'; user: ArgType<'user'> }) { if (!message.author.isOwner()) return await message.util.reply(`${emojis.error} Only my developers can run this command.`); - const superUsers: string[] = getShared('superUsers'); + const superUsers: string[] = this.client.utils.getShared('superUsers'); if (args.action === 'add' ? superUsers.includes(args.user.id) : !superUsers.includes(args.user.id)) return message.util.reply( `${emojis.warn} ${format.input(args.user.tag)} is ${args.action === 'add' ? 'already' : 'not'} a superuser.` ); - const success = await insertOrRemoveFromShared(args.action, 'superUsers', args.user.id).catch(() => false); + const success = await this.client.utils.insertOrRemoveFromShared(args.action, 'superUsers', args.user.id).catch(() => false); if (success) { return await message.util.reply( diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index 9491d19..600aeac 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -135,15 +135,15 @@ export default class TestCommand extends BushCommand { return await message.util.reply({ content: 'this is content', components: ButtonRows, embeds }); } else if (['delete slash commands'].includes(args.feature?.toLowerCase())) { if (!message.guild) return await message.util.reply(`${emojis.error} This test can only be run in a guild.`); - await client.guilds.fetch(); + await this.client.guilds.fetch(); const promises: Promise<Collection<string, ApplicationCommand>>[] = []; - client.guilds.cache.each((guild) => { + this.client.guilds.cache.each((guild) => { promises.push(guild.commands.set([])); }); await Promise.all(promises); - await client.application!.commands.fetch(); - await client.application!.commands.set([]); + await this.client.application!.commands.fetch(); + await this.client.application!.commands.set([]); return await message.util.reply(`${emojis.success} Removed guild commands and global commands.`); } else if (['drop down', 'drop downs', 'select menu', 'select menus'].includes(args.feature?.toLowerCase())) { @@ -166,7 +166,7 @@ export default class TestCommand extends BushCommand { }); // eslint-disable-next-line @typescript-eslint/no-misused-promises - client.ws.on(GatewayDispatchEvents.InteractionCreate, async (i: any) => { + this.client.ws.on(GatewayDispatchEvents.InteractionCreate, async (i: any) => { if (i?.data?.custom_id !== 'test;modal' || i?.data?.component_type !== 2) return; if (i?.message?.id !== m.id) return; |