forked from engineering/cloudservices
change how args works
parent
02e41276cf
commit
ee9588c077
|
@ -16,25 +16,25 @@ export default class Eval extends Command {
|
||||||
this.guildOnly = false;
|
this.guildOnly = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run(message: Message, args: string[]) {
|
public async run(message: Message) {
|
||||||
try {
|
try {
|
||||||
const evalMessage = message.content.slice(this.client.config.prefix.length).trim().split(' ').slice(1);
|
const args = message.content.slice(this.client.config.prefix.length).trim().split(' ').slice(1);
|
||||||
let evalString = evalMessage.join(' ').trim();
|
let evalString = args.join(' ').trim();
|
||||||
let evaled: any;
|
let evaled: any;
|
||||||
let depth = 0;
|
let depth = 0;
|
||||||
|
|
||||||
if (args[0] && args[0].startsWith('-d')) {
|
if (args[0] && args[0].startsWith('-d')) {
|
||||||
depth = Number(args[0].replace('-d', ''));
|
depth = Number(args[0].replace('-d', ''));
|
||||||
if (!depth || depth < 0) depth = 0;
|
if (!depth || depth < 0) depth = 0;
|
||||||
const index = evalMessage.findIndex((v) => v.startsWith('-d')) + 1;
|
args.shift();
|
||||||
await message.channel.createMessage(`depth: ${evalMessage.slice(index).join(' ').trim()}`);
|
await message.channel.createMessage(`depth: ${args.join(' ').trim()}`);
|
||||||
evalString = evalMessage.slice(index).join(' ').trim();
|
evalString = args.join(' ').trim();
|
||||||
}
|
}
|
||||||
await message.channel.createMessage(`eval after depth: ${evalString}\n${args.join()}`);
|
await message.channel.createMessage(`eval after depth: ${evalString}\n${args.join()}`);
|
||||||
if (args[0] === '-a') {
|
if (args[0] === '-a') {
|
||||||
const index = evalMessage.findIndex((v) => v === '-a') + 1;
|
args.shift();
|
||||||
await message.channel.createMessage(`async: ${evalMessage.slice(index).join(' ').trim()}`);
|
await message.channel.createMessage(`async: ${args.join(' ').trim()}`);
|
||||||
evalString = `(async () => { ${evalMessage.slice(index).join(' ').trim()} })()`;
|
evalString = `(async () => { ${args.join(' ').trim()} })()`;
|
||||||
}
|
}
|
||||||
await message.channel.createMessage(`eval after async: ${evalString}\n${args.join()}`);
|
await message.channel.createMessage(`eval after async: ${evalString}\n${args.join()}`);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue