diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-04 15:25:32 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-04 15:25:32 -0400 |
commit | cf564dbb6435886f97e2e9870363144386af368d (patch) | |
tree | d535cd73f24a145ca9d7ce1a0e1174cba0d38b31 /src/commands/dev | |
parent | 34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a (diff) | |
download | tanzanite-cf564dbb6435886f97e2e9870363144386af368d.tar.gz tanzanite-cf564dbb6435886f97e2e9870363144386af368d.tar.bz2 tanzanite-cf564dbb6435886f97e2e9870363144386af368d.zip |
mute command
Diffstat (limited to 'src/commands/dev')
-rw-r--r-- | src/commands/dev/eval.ts | 2 | ||||
-rw-r--r-- | src/commands/dev/reload.ts | 6 | ||||
-rw-r--r-- | src/commands/dev/testDuration.ts | 54 |
3 files changed, 60 insertions, 2 deletions
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 4896945..ebf055b 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -259,7 +259,7 @@ export default class EvalCommand extends BushCommand { } else { embed.addField('📥 Input', await this.client.util.codeblock(inputJS, 1024, 'js')); } - embed.addField('📤 Output', await this.client.util.codeblock(e?.stack, 1024, 'js')); + embed.addField('📤 Output', await this.client.util.codeblock(typeof e === 'object' ? e?.stack : e, 1024, 'js')); } if (!args.silent && !message.util.isSlash) { await message.util.reply({ embeds: [embed], ephemeral: args.silent }); diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index d932816..4a69098 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -46,7 +46,11 @@ export default class ReloadCommand extends BushCommand { return message.util.send(`🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`); } catch (e) { return message.util.send( - `An error occurred while reloading:\n${await this.client.util.codeblock(e.stack, 2048 - 34, 'js')}` + `An error occurred while reloading:\n${await this.client.util.codeblock( + typeof e === 'object' ? e?.stack : e, + 2048 - 34, + 'js' + )}` ); } } diff --git a/src/commands/dev/testDuration.ts b/src/commands/dev/testDuration.ts new file mode 100644 index 0000000..bf30840 --- /dev/null +++ b/src/commands/dev/testDuration.ts @@ -0,0 +1,54 @@ +import { stripIndents } from 'common-tags'; +import { Message } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; + +export default class TestDurationCommand extends BushCommand { + public constructor() { + super('testduration', { + aliases: ['testduration'], + category: 'dev', + description: { + content: 'Tests duration parsing.', + usage: 'testduration [reason]', + examples: ['testduration'] + }, + args: [ + { + id: 'reason', + type: 'contentWithDuration', + match: 'rest', + prompt: { + start: 'Enter text and a duration here.', + retry: '{error} Error parsing duration and text.', + optional: true + } + } + ], + slash: true, + slashOptions: [ + { + type: 'STRING', + name: 'reason', + description: 'Enter text and a duration here.', + required: false + } + ], + hidden: true, + ownerOnly: true + }); + } + + async exec( + message: Message | BushSlashMessage, + { reason }: { reason?: { duration: number; contentWithoutTime: string } } + ): Promise<unknown> { + const rawDuration = reason.duration; + const text = reason.contentWithoutTime; + const humanizedDuration = this.client.util.humanizeDuration(rawDuration); + return await message.util.reply(stripIndents` + **rawDuration:** ${rawDuration} + **text:** ${text} + **humanizedDuration:** ${humanizedDuration}`); + } +} |