aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/dev')
-rw-r--r--src/commands/dev/reload.ts4
-rw-r--r--src/commands/dev/sh.ts8
-rw-r--r--src/commands/dev/superUser.ts39
3 files changed, 23 insertions, 28 deletions
diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts
index 91cabfb..f7afbca 100644
--- a/src/commands/dev/reload.ts
+++ b/src/commands/dev/reload.ts
@@ -45,7 +45,9 @@ export default class ReloadCommand extends BushCommand {
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 util.codeblock(e?.stack || e, 2048 - 34, 'js')}`);
+ return message.util.send(
+ `An error occurred while reloading:\n${await util.codeblock(e?.stack || e, 2048 - 34, 'js', true)}`
+ );
}
}
}
diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts
index 93f0d40..067a0e6 100644
--- a/src/commands/dev/sh.ts
+++ b/src/commands/dev/sh.ts
@@ -47,7 +47,7 @@ export default class ShCommand extends BushCommand {
.setFooter(message.author.tag, message.author.avatarURL({ dynamic: true }) ?? undefined)
.setTimestamp()
.setTitle('Shell Command')
- .addField('📥 Input', await util.codeblock(input, 1024, 'sh'))
+ .addField('📥 Input', await util.codeblock(input, 1024, 'sh', true))
.addField('Running', util.emojis.loading);
await message.util.reply({ embeds: [embed] });
@@ -69,15 +69,15 @@ export default class ShCommand extends BushCommand {
.setColor(util.colors.success)
.spliceFields(1, 1);
- if (stdout) embed.addField('📤 stdout', await util.codeblock(stdout, 1024, 'json'));
- if (stderr) embed.addField('📤 stderr', await util.codeblock(stderr, 1024, 'json'));
+ if (stdout) embed.addField('📤 stdout', await util.codeblock(stdout, 1024, 'json', true));
+ if (stderr) embed.addField('📤 stderr', await util.codeblock(stderr, 1024, 'json', true));
} catch (e) {
embed
.setTitle(`${util.emojis.errorFull} An error occurred while executing.`)
.setColor(util.colors.error)
.spliceFields(1, 1);
- embed.addField('📤 Output', await util.codeblock(e?.stack, 1024, 'js'));
+ embed.addField('📤 Output', await util.codeblock(e?.stack, 1024, 'js', true));
}
await message.util.edit({ embeds: [embed] });
}
diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts
index 4bab8a1..a36972b 100644
--- a/src/commands/dev/superUser.ts
+++ b/src/commands/dev/superUser.ts
@@ -42,36 +42,29 @@ export default class SuperUserCommand extends BushCommand {
public override async exec(
message: BushMessage | BushSlashMessage,
- args: { action: 'add' | 'remove'; user: User }
+ { action, user }: { action: 'add' | 'remove'; user: User }
): Promise<unknown> {
if (!message.author.isOwner())
return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`);
- if (!args.user?.id)
- return await message.util.reply(
- `${util.emojis.error} I fucked up here is args ${await util.inspectCleanRedactCodeblock(args, 'ts')}`
- );
-
const superUsers: string[] = (await Global.findByPk(client.config.environment))?.superUsers ?? [];
- let success;
- if (args.action === 'add') {
- if (superUsers.includes(args.user.id)) {
- return message.util.reply(`${util.emojis.warn} \`${args.user.tag}\` is already a superuser.`);
- }
- success = await util.insertOrRemoveFromGlobal('add', 'superUsers', args.user.id).catch(() => false);
- } else {
- if (!superUsers.includes(args.user.id)) {
- return message.util.reply(`${util.emojis.warn} \`${args.user.tag}\` is not superuser.`);
- }
- success = await util.insertOrRemoveFromGlobal('remove', 'superUsers', args.user.id).catch(() => false);
- }
+
+ if (action === 'add' ? superUsers.includes(user.id) : !superUsers.includes(user.id))
+ return message.util.reply(`${util.emojis.warn} \`${user.tag}\` is ${action === 'add' ? 'already' : 'not'} a superuser.`);
+
+ const success = await util.insertOrRemoveFromGlobal(action, 'superUsers', user.id).catch(() => false);
+
if (success) {
- const responses = [args.action == 'remove' ? '' : 'made', args.action == 'remove' ? 'is no longer' : ''];
- return message.util.reply(`${util.emojis.success} ${responses[0]} \`${args.user.tag}\` ${responses[1]} a superuser.`);
+ return await message.util.reply(
+ `${util.emojis.success} ${action == 'remove' ? '' : 'made'} \`${user.tag}\` ${
+ action == 'remove' ? 'is no longer ' : ''
+ }a superuser.`
+ );
} else {
- const response = [args.action == 'remove' ? `removing` : 'making', args.action == 'remove' ? `from` : 'to'];
- return message.util.reply(
- `${util.emojis.error} There was an error ${response[0]} \`${args.user.tag}\` ${response[1]} the superuser list.`
+ return await message.util.reply(
+ `${util.emojis.error} There was an error ${action == 'remove' ? `removing` : 'making'} \`${user.tag}\` ${
+ action == 'remove' ? `from` : 'to'
+ } the superuser list.`
);
}
}