change how args works

merge-requests/4/head
Bsian 2020-06-15 23:05:29 +01:00
parent 02e41276cf
commit ee9588c077
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 9 additions and 9 deletions

View File

@ -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()}`);