aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev/superUser.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-05 13:45:44 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-05 13:45:44 -0400
commit81d69f983983ac71dbdbd5f13e2f2d8ddc35dced (patch)
tree6a06124a6696bb4036607d179972aa889b7b3769 /src/commands/dev/superUser.ts
parent93e8fce44ec1dd3294b1c785d93d3f8b00ee4cef (diff)
downloadtanzanite-81d69f983983ac71dbdbd5f13e2f2d8ddc35dced.tar.gz
tanzanite-81d69f983983ac71dbdbd5f13e2f2d8ddc35dced.tar.bz2
tanzanite-81d69f983983ac71dbdbd5f13e2f2d8ddc35dced.zip
cleaning up and some imporvements to the stats command
Diffstat (limited to 'src/commands/dev/superUser.ts')
-rw-r--r--src/commands/dev/superUser.ts39
1 files changed, 16 insertions, 23 deletions
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.`
);
}
}