diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-08 20:08:16 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-08 20:08:16 -0500 |
commit | e0531157a745ac6178d55cc159b5932fa36ff20f (patch) | |
tree | a8de340d0c48269619e9bfde536932eb08556593 /src/commands/dev/eval.ts | |
parent | 0e160ae77477f0986a02746e84158329299f438f (diff) | |
download | tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.tar.gz tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.tar.bz2 tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.zip |
database migrations - use jsonb over text + JSON.parse, refactor bad word & automod - store word in shared db
closes: #53
Diffstat (limited to 'src/commands/dev/eval.ts')
-rw-r--r-- | src/commands/dev/eval.ts | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 5b2f27a..4eb25dc 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -8,6 +8,7 @@ import { Guild, Level, ModLog, + Shared, StickyRole, type ArgType } from '#lib'; @@ -132,6 +133,15 @@ export default class EvalCommand extends BushCommand { prompt: 'Would you like to inspect the prototype chain to find methods?', slashType: 'BOOLEAN', optional: true + }, + { + id: 'async', + description: 'Whether or not to wrap the code in an async function.', + match: 'flag', + flag: '--async', + prompt: 'Would you like to wrap the code in an async function?', + slashType: 'BOOLEAN', + optional: true } ], slash: true, @@ -144,8 +154,8 @@ export default class EvalCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, args: { - sel_depth: ArgType<'integer'>; code: ArgType<'string'>; + sel_depth: ArgType<'integer'>; sudo: ArgType<'boolean'>; silent: ArgType<'boolean'>; deleteMSG: ArgType<'boolean'>; @@ -153,6 +163,7 @@ export default class EvalCommand extends BushCommand { hidden: ArgType<'boolean'>; show_proto: ArgType<'boolean'>; show_methods: ArgType<'boolean'>; + async: ArgType<'boolean'>; } ) { if (!message.author.isOwner()) @@ -161,7 +172,8 @@ export default class EvalCommand extends BushCommand { await message.interaction.deferReply({ ephemeral: args.silent }); } const isTypescript = args.typescript || args.code.includes('```ts'); - const rawCode = args.code.replace(/[“”]/g, '"').replace(/```*(?:js|ts)?/g, ''); + let rawCode = args.code.replace(/[“”]/g, '"').replace(/```*(?:js|ts)?/g, ''); + if (args.async) rawCode = `(async () => {${rawCode}})()`; const code: { ts: string | null; js: string; lang: 'ts' | 'js' } = { ts: isTypescript ? rawCode : null, @@ -237,4 +249,4 @@ export default class EvalCommand extends BushCommand { } } -/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|MessageActionRow|MessageAttachment|MessageButton|MessageCollector|MessageSelectMenu|ReactionCollector|Util|Canvas} VSCodePleaseDontRemove */ +/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|MessageActionRow|MessageAttachment|MessageButton|MessageCollector|MessageSelectMenu|ReactionCollector|Util|Canvas|Shared} VSCodePleaseDontRemove */ |