diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-27 18:08:14 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-27 18:08:14 -0400 |
commit | 747b3c8302245699294b671d19b3d31d63f80bc1 (patch) | |
tree | ad3d987bb38d5bdaed67e6aca1263fb06331f746 /src/commands/dev | |
parent | 4176b6258e44e4a095376aaf0f4c687244243a69 (diff) | |
download | tanzanite-747b3c8302245699294b671d19b3d31d63f80bc1.tar.gz tanzanite-747b3c8302245699294b671d19b3d31d63f80bc1.tar.bz2 tanzanite-747b3c8302245699294b671d19b3d31d63f80bc1.zip |
did this a while ago so I don't remeber what I did
Diffstat (limited to 'src/commands/dev')
-rw-r--r-- | src/commands/dev/eval.ts | 19 | ||||
-rw-r--r-- | src/commands/dev/reload.ts | 26 | ||||
-rw-r--r-- | src/commands/dev/setLevel.ts | 22 | ||||
-rw-r--r-- | src/commands/dev/superUser.ts | 6 |
4 files changed, 37 insertions, 36 deletions
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 310a2c5..04c5158 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -1,12 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { exec } from 'child_process'; import { Constants } from 'discord-akairo'; +import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction, MessageEmbed, MessageEmbedOptions, Util } from 'discord.js'; import { transpile } from 'typescript'; import { inspect, promisify } from 'util'; import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushSlashMessage } from '../../lib/extensions/BushInteractionMessage'; import { BushMessage } from '../../lib/extensions/BushMessage'; +import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; const clean = (text) => { if (typeof text === 'string') { @@ -79,43 +80,43 @@ export default class EvalCommand extends BushCommand { { name: 'code', description: 'The code you would like to evaluate.', - type: 'STRING', + type: ApplicationCommandOptionType.STRING, required: true }, { name: 'sel_depth', description: 'How deep to display the output.', - type: 'INTEGER', + type: ApplicationCommandOptionType.INTEGER, required: false }, { name: 'sudo', description: 'Whether or not to override checks.', - type: 'BOOLEAN', + type: ApplicationCommandOptionType.BOOLEAN, required: false }, { name: 'silent', description: 'Whether or not to make the response silent', - type: 'BOOLEAN', + type: ApplicationCommandOptionType.BOOLEAN, required: false }, { name: 'typescript', description: 'Whether or not to compile the code from typescript.', - type: 'BOOLEAN', + type: ApplicationCommandOptionType.BOOLEAN, required: false }, { name: 'hidden', description: 'Whether or not to show hidden items.', - type: 'BOOLEAN', + type: ApplicationCommandOptionType.BOOLEAN, required: false }, { name: 'show_proto', description: 'Show prototype.', - type: 'BOOLEAN', + type: ApplicationCommandOptionType.BOOLEAN, required: false } ] @@ -135,7 +136,7 @@ export default class EvalCommand extends BushCommand { show_proto: boolean; } ): Promise<unknown> { - if (!this.client.config.owners.includes(message.author.id)) + if (!message.author.isOwner()) return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); if (message.util.isSlash) { await (message as BushSlashMessage).interaction.defer({ ephemeral: args.silent }); diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index f5fee88..07218f2 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -1,7 +1,7 @@ -import { stripIndent } from 'common-tags'; -import { Message } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord-api-types'; import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushSlashMessage } from '../../lib/extensions/BushInteractionMessage'; +import { BushMessage } from '../../lib/extensions/BushMessage'; +import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; export default class ReloadCommand extends BushCommand { constructor() { @@ -24,7 +24,7 @@ export default class ReloadCommand extends BushCommand { typing: true, slashOptions: [ { - type: 'BOOLEAN', + type: ApplicationCommandOptionType.BOOLEAN, name: 'fast', description: 'Whether to use esbuild for fast compiling or not', required: false @@ -34,23 +34,21 @@ export default class ReloadCommand extends BushCommand { }); } - private async getResponse(fast: boolean): Promise<string> { + public async exec(message: BushMessage | BushSlashMessage, { fast }: { fast: boolean }): Promise<unknown> { + if (!message.author.isOwner()) + return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + try { const s = new Date(); await this.client.util.shell(`yarn build-${fast ? 'esbuild' : 'tsc'}`); this.client.commandHandler.reloadAll(); this.client.listenerHandler.reloadAll(); this.client.inhibitorHandler.reloadAll(); - return `🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`; + return message.util.send(`🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`); } catch (e) { - return stripIndent` - An error occured while reloading: - ${await this.client.util.haste(e.stack)} - `; + return message.util.send( + `An error occurred while reloading:\n${await this.client.util.codeblock(e.stack, 2048 - 34, 'js')}` + ); } } - - public async exec(message: Message | BushSlashMessage, { fast }: { fast: boolean }): Promise<void> { - await message.util.send(await this.getResponse(fast)); - } } diff --git a/src/commands/dev/setLevel.ts b/src/commands/dev/setLevel.ts index f536109..7e07ce0 100644 --- a/src/commands/dev/setLevel.ts +++ b/src/commands/dev/setLevel.ts @@ -1,5 +1,8 @@ -import { Message, User } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord-api-types'; +import { User } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushMessage } from '../../lib/extensions/BushMessage'; +import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; import { Level } from '../../lib/models'; import AllowedMentions from '../../lib/utils/AllowedMentions'; @@ -34,13 +37,13 @@ export default class SetLevelCommand extends BushCommand { ownerOnly: true, slashOptions: [ { - type: 'USER', + type: /* 'USER' */ ApplicationCommandOptionType.USER, name: 'user', description: 'The user to change the level of', required: true }, { - type: 'INTEGER', + type: /* 'INTEGER' */ ApplicationCommandOptionType.INTEGER, name: 'level', description: 'The level to set the user to', required: true @@ -50,7 +53,10 @@ export default class SetLevelCommand extends BushCommand { }); } - private async setLevel(user: User, level: number): Promise<string> { + async exec(message: BushMessage | BushSlashMessage, { user, level }: { user: User; level: number }): Promise<unknown> { + if (!message.author.isOwner()) + return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + const [levelEntry] = await Level.findOrBuild({ where: { id: user.id @@ -60,12 +66,8 @@ export default class SetLevelCommand extends BushCommand { } }); await levelEntry.update({ xp: Level.convertLevelToXp(level) }); - return `Successfully set level of <@${user.id}> to \`${level}\` (\`${levelEntry.xp}\` XP)`; - } - - async exec(message: Message, { user, level }: { user: User; level: number }): Promise<void> { - await message.util.send({ - content: await this.setLevel(user, level), + return await message.util.send({ + content: `Successfully set level of <@${user.id}> to \`${level}\` (\`${levelEntry.xp}\` XP)`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 4562e6f..773209c 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -42,8 +42,8 @@ export default class SuperUserCommand extends BushCommand { return { action, user }; } public async exec(message: BushMessage, args: { action: 'add' | 'remove'; user: User }): Promise<unknown> { - if (!this.client.config.owners.includes(message.author.id)) - return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command...`); + if (!message.author.isOwner()) + return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); const superUsers = (await Global.findByPk(this.client.config.dev ? 'development' : 'production')).superUsers; let success; @@ -59,7 +59,7 @@ export default class SuperUserCommand extends BushCommand { success = await this.client.util.insertOrRemoveFromGlobal('remove', 'superUsers', args.user.id).catch(() => false); } if (success) { - const responses = [args.action == 'remove' ? `` : 'made', args.action == 'remove' ? 'is no longer' : '']; + const responses = [args.action == 'remove' ? '' : 'made', args.action == 'remove' ? 'is no longer' : '']; return message.util.reply( `${this.client.util.emojis.success} ${responses[0]} \`${args.user.tag}\` ${responses[1]} a superuser.` ); |