Advertisement
Guest User

Eval

a guest
Jan 6th, 2020
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. const Command = require('../Classes/Command'); const Discord = require('discord.js'); class Eval extends Command {
  2. constructor(client) {
  3. super(client, {
  4. name: 'eval',
  5. description: 'Evaluates JavaScript code.',
  6. category: 'Development',
  7. usage: ',eval [code]',
  8. aliases: ['e']
  9. });
  10. }
  11. async run(message, args) {
  12. if (message.author.id !== '630039758776827926') return message.author.send("You're not permitted to use the Eval Command!");
  13. let evaled;
  14. try {
  15. evaled = await eval(args.join(' ').trim());
  16. } catch (err) {
  17. const embed2 = new Discord.RichEmbed();
  18. //embed2.setAuthor(client.user.username, client.user.avatarURL);
  19. embed2.setColor('#FF0000');
  20. embed2.setTitle('JAVASCRIPT EVALUATION');
  21. embed2.setDescription(\ERROR`
  22. js\n${err}\n
  23. );
  24. embed2.setTimestamp();
  25. embed2.setFooter(${this.client.user.username} | Requested by ${message.author.username}#${message.author.discriminator}, this.client.user.avatarURL);
  26. return message.channel.send(embed2);
  27. }
  28. if (typeof evaled === 'string') {
  29. evaled = evaled.replace(this.client.token, '[TOKEN]');
  30. }
  31. if (typeof evaled === 'object') {
  32. evaled = require('util').inspect(evaled, {depth: 0});
  33. }
  34. if (evaled == undefined) {
  35. evaled = 'undefined';
  36. }
  37. if (evaled.length > 1900) {
  38. const overloadEmbed = new Discord.RichEmbed();
  39. overloadEmbed.setTitle('__JAVASCRIPT EVALUATION__');
  40. overloadEmbed.setColor('ORANGE');
  41. overloadEmbed.setDescription('The result was too long to be sent, please try again later.');
  42. overloadEmbed.setTimestamp();
  43. overloadEmbed.setFooter(${this.client.user.username} | Requested by ${message.author.username}#${message.author.discriminator}`,
  44. this.client.user.avatarURL);
  45. return message.channel.send(overloadEmbed);
  46. }
  47. const embed1 = new Discord.RichEmbed()
  48. //.setAuthor(client.user.username, client.user.avatarURL)
  49. .setColor('#00FF00')
  50. .setTitle('JAVASCRIPT EVALUATION')
  51. .setDescription(\``js\n${evaled}\n
  52. )
  53. .setTimestamp()
  54. .setFooter(${this.client.user.username} | Requested by ${message.author.username}#${message.author.discriminator}`, this.client.user.avatarURL);
  55. message.channel.send(embed1);
  56. }
  57. }
  58. module.exports = Eval;
  59. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement