2018-12-30 01:20:24 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
|
|
|
|
class EvalCommand extends Command {
|
2019-01-02 08:09:45 +01:00
|
|
|
constructor() {
|
|
|
|
super('eval', {
|
|
|
|
aliases: ['eval'],
|
|
|
|
category: 'owner',
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'eval',
|
2019-01-14 11:41:15 +01:00
|
|
|
type: 'string',
|
|
|
|
match: 'rest'
|
2019-01-02 08:09:45 +01:00
|
|
|
}
|
|
|
|
],
|
|
|
|
ownerOnly: 'true',
|
|
|
|
description: {
|
2018-12-30 01:20:24 +01:00
|
|
|
content: 'Execute javascript',
|
|
|
|
usage: '[code]',
|
|
|
|
examples: ['message.channel.send(\'Hi\')']
|
|
|
|
}
|
2019-01-02 08:09:45 +01:00
|
|
|
});
|
|
|
|
}
|
2018-12-30 01:20:24 +01:00
|
|
|
|
2019-01-02 08:09:45 +01:00
|
|
|
async exec(message, args) {
|
|
|
|
const clean = text => {
|
|
|
|
if (typeof(text) === 'string')
|
|
|
|
return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203));
|
|
|
|
else
|
|
|
|
return text;
|
|
|
|
};
|
2018-12-30 01:20:24 +01:00
|
|
|
|
2019-01-02 08:09:45 +01:00
|
|
|
try {
|
|
|
|
const code = args.eval;
|
|
|
|
let evaled = eval(code);
|
|
|
|
|
|
|
|
if (typeof evaled !== 'string')
|
|
|
|
evaled = require('util').inspect(evaled);
|
2019-01-14 16:53:56 +01:00
|
|
|
|
2019-11-22 12:30:20 +01:00
|
|
|
const evalEmbed = this.client.util.embed()
|
2019-01-14 16:53:56 +01:00
|
|
|
.setColor('#00FF00')
|
2019-05-11 17:58:11 +02:00
|
|
|
.setTitle('<a:orangejustice:522142267490697236> Eval succes <a:orangejustice:522142267490697236>')
|
2019-01-14 16:53:56 +01:00
|
|
|
.setThumbnail('https://cdn4.iconfinder.com/data/icons/gradient-ui-1/512/success-512.png')
|
|
|
|
.addField('Input', `\`\`\`js\n${code}\`\`\``)
|
|
|
|
.addField('Output', `\`\`\`js\n${clean(evaled)}\`\`\``)
|
|
|
|
.setTimestamp();
|
|
|
|
|
|
|
|
message.channel.send(evalEmbed);
|
2019-01-02 08:09:45 +01:00
|
|
|
} catch (err) {
|
2019-11-22 12:30:20 +01:00
|
|
|
const errorEmbed = this.client.util.embed()
|
2019-01-14 16:53:56 +01:00
|
|
|
.setColor('#FF0000')
|
2019-05-11 17:58:11 +02:00
|
|
|
.setTitle('Eval failed <:sadpepe:534399181679230986>')
|
2019-01-14 16:53:56 +01:00
|
|
|
.setThumbnail('https://cdn4.iconfinder.com/data/icons/the-weather-is-nice-today/64/weather_48-512.png')
|
|
|
|
.addField('Input', `\`\`\`js\n${args.eval}\`\`\``)
|
|
|
|
.addField('Output', `\`\`\`js\n${clean(err)}\`\`\``)
|
|
|
|
.setTimestamp();
|
|
|
|
|
|
|
|
message.channel.send(errorEmbed);
|
2019-01-02 08:09:45 +01:00
|
|
|
}
|
|
|
|
}
|
2018-12-30 01:20:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = EvalCommand;
|