Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

discordjs eval

const Discord = require('discord.js');

module.exports = 
{
    name: 'eval',
    description: 'Execute javascript code [DEVELOPER ONLY]',
    execute(message, args, client) 
    {
        try
        {
            if (message.author.id == urAccountID)
            {
                
                var msg = message.content.split(" ").slice(1).join(" ")

                let evaled = eval(msg);

                if (evaled === undefined)
                {
                    if (msg.includes("console.log"))
                    {
                        var msgtmp = msg.split('"');

                        var embed = new Discord.MessageEmbed()
                        .addFields
                        (
                            { name: "Code", value: msg},
                            { name: "Result", value: msgtmp[1]},
                        )
                        .setColor('BLACK');
                        message.channel.send(embed);
                        return;
                    }
					
					//you can make it eval functions if you want but whatever
                    if (msg.includes("function"))
                    {
                        var embed = new Discord.MessageEmbed()
                        .addFields
                        (
                            { name: "Code", value: msg},
                            { name: "Message", value: "Cannot evaluate functions"},
                        )
                        .setColor('BLACK');
                        message.channel.send(embed);
                        return
                    }
                }
                var embed = new Discord.MessageEmbed()
                .setTitle("Bot Evalatuion")
                .addFields
                (
                    { name: "Code", value: msg},
                    { name: "Result", value: evaled},
                )
                .setColor('BLACK');
                message.channel.send(embed);
            }
            else
            {
                var embed = new Discord.MessageEmbed()
                .setTitle("Bot Evalatuion")
                .setFooter("You do not have permission to run evalauation")
                .setColor('BLACK');
                message.channel.send(embed);
            }
        }
        catch (ex)
        {
            var embed = new Discord.MessageEmbed()
            .addFields
            (
                { name: "Error", value: ex},
            )
            .setColor('BLACK');
            message.channel.send(embed);
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: click outside react component 
Javascript :: javascrpt formatBytes 
Javascript :: chrome input disable autofill 
Javascript :: Checking Empty JS Object 
Javascript :: how to fix Composer could not find a composer.json file in Z:xampp 7312htdocsproject_karakter-master 
Javascript :: js string to node 
Javascript :: javascript cahnge colour of strokerect 
Javascript :: object.keys 
Javascript :: react native dimensions window vs screen 
Javascript :: cypress ignore error 
Javascript :: get last element in an array jqury 
Javascript :: send url by whatsapp in javascript 
Javascript :: split date 
Javascript :: redux dev tools 
Javascript :: npm yarn run shell script 
Javascript :: javascript findindex 
Javascript :: await useeffect javascript 
Javascript :: js navigate to anchor 
Javascript :: submit form in vue 
Javascript :: Javascript how to compare three numbers 
Javascript :: install aos angular 10 
Javascript :: dockerfile copy ignore node_modules 
Javascript :: javascript minimum number in array 
Javascript :: javascript sql 
Javascript :: request entity too large 
Javascript :: react forwardref 
Javascript :: javascript assignment operators 
Javascript :: react native shadow above 
Javascript :: Remove duplication from array in javascript 
Javascript :: javascript disable button 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =