From ee9588c0770d1172b763d66e239150f032ae0dd7 Mon Sep 17 00:00:00 2001 From: Bsian Date: Mon, 15 Jun 2020 23:05:29 +0100 Subject: [PATCH] change how args works --- src/commands/eval.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/commands/eval.ts b/src/commands/eval.ts index 9c8321e..0b26a08 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -16,25 +16,25 @@ export default class Eval extends Command { this.guildOnly = false; } - public async run(message: Message, args: string[]) { + public async run(message: Message) { try { - const evalMessage = message.content.slice(this.client.config.prefix.length).trim().split(' ').slice(1); - let evalString = evalMessage.join(' ').trim(); + const args = message.content.slice(this.client.config.prefix.length).trim().split(' ').slice(1); + let evalString = args.join(' ').trim(); let evaled: any; let depth = 0; if (args[0] && args[0].startsWith('-d')) { depth = Number(args[0].replace('-d', '')); if (!depth || depth < 0) depth = 0; - const index = evalMessage.findIndex((v) => v.startsWith('-d')) + 1; - await message.channel.createMessage(`depth: ${evalMessage.slice(index).join(' ').trim()}`); - evalString = evalMessage.slice(index).join(' ').trim(); + args.shift(); + await message.channel.createMessage(`depth: ${args.join(' ').trim()}`); + evalString = args.join(' ').trim(); } await message.channel.createMessage(`eval after depth: ${evalString}\n${args.join()}`); if (args[0] === '-a') { - const index = evalMessage.findIndex((v) => v === '-a') + 1; - await message.channel.createMessage(`async: ${evalMessage.slice(index).join(' ').trim()}`); - evalString = `(async () => { ${evalMessage.slice(index).join(' ').trim()} })()`; + args.shift(); + await message.channel.createMessage(`async: ${args.join(' ').trim()}`); + evalString = `(async () => { ${args.join(' ').trim()} })()`; } await message.channel.createMessage(`eval after async: ${evalString}\n${args.join()}`);