Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const config = require('../config.json');
- const log = require(`leekslazylogger`),
- { inspect } = require("util"),
- vm = require("vm");
- codeContext = {};
- vm.createContext(codeContext);
- module.exports = {
- name: 'eval',
- description: 'не ебу. что сюда писать?',
- usage: '[eval <code>]',
- aliases: ['e'],
- example: 'eval <code>',
- args: false,
- cooldown: config.cooldown,
- guildOnly: true,
- execute(message, args) {
- if(!["tvoi id", "eshe id"].includes(message.author.id)) return
- const client = message.client;
- var guild = message.guild
- var channel = message.channel
- var author = message.author
- let embed = new Discord.RichEmbed()
- const code = args.join(" ");
- const token = bot.token.split("").join("[^]{0,2}");
- const rev = bot.token.split("").reverse().join("[^]{0,2}");
- const filter = new RegExp(`${token}|${rev}`, "g");
- try {
- let hrDiff;
- const hrStart = process.hrtime();
- hrDiff = process.hrtime(hrStart);
- let output = eval(code);
- let asd = output;
- if (output instanceof Promise || (Boolean(output) && typeof output.then === "function" && typeof output.catch === "function")) output = await output;
- output = inspect(output, { depth: 0, maxArrayLength: null });
- output = output.replace(filter, `[ ${bot.user.username} Token]`);
- output = clean(output);
- if (output.length < 1950) {
- let embed = new Discord.RichEmbed()
- .setAuthor(message.author.tag, message.author.avatarURL)
- .setDescription(`\`\`\`fix\nOutput type: ${typeof asd}\nExecution time: ${hrDiff[0] > 0 ? `${hrDiff[0]}s ` : ''}${hrDiff[1] / 1000000}ms\nOutput:\`\`\`\n\`\`\`json\n\n${output}\n\`\`\``)
- message.channel.send(embed).then(async m => {
- await m.react('✅')
- await m.react('📝')
- let collector = m.createReactionCollector((reaction, user) => user.id === message.author.id)
- collector.on("collect", async reaction => {
- if(reaction.emoji.name === "✅"){
- collector.stop();
- m.delete();
- } else if (reaction.emoji.name === "📝"){
- message.author.send(`${args.join(' ')}`, { split: "\n", code: "js" });
- }
- });
- });
- } else {
- message.author.send(`${output}`, { split: "\n", code: "js" });
- }
- } catch (error) {
- let errbed = new Discord.RichEmbed()
- .setAuthor(`Error`, message.author.avatarURL)
- .setDescription(`Error \`\`\`js\n${error}\`\`\``)
- message.channel.send(errbed);
- message.react("🇫")
- }
- function clean(text) {
- return text
- .replace(/`/g, "`" + String.fromCharCode(8203))
- .replace(/@/g, "@" + String.fromCharCode(8203));
- }
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement