Skip to content

Instantly share code, notes, and snippets.

@Lewdcario
Last active August 6, 2022 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Lewdcario/c457c12f7eabfb4115c2067d634d549a to your computer and use it in GitHub Desktop.
Save Lewdcario/c457c12f7eabfb4115c2067d634d549a to your computer and use it in GitHub Desktop.
Discord.js sample eval command
const { inspect } = require('util');
client.on('messageCreate', async message => {
const args = message.content.split(' ');
const command = args.shift().toLowerCase();
if (command === 'eval') {
// Put your userID here
if (message.author.id !== 'ownerID') return;
let evaled;
try {
evaled = await eval(args.join(' '));
message.channel.send(inspect(evaled));
console.log(inspect(evaled));
}
catch (error) {
console.error(error);
message.reply('there was an error during evaluation.');
}
}
});
@CoolingJam
Copy link

nice

Copy link

ghost commented Apr 9, 2020

lol

@renorari
Copy link

友達が使っていました。

@LeMinebloxer
Copy link

Does that work on v.12 or discord.js?

@geenva
Copy link

geenva commented Sep 11, 2020

Does that work on v.12 or discord.js?
replace client to bot. it should work then

Copy link

ghost commented Sep 15, 2020

This does not function.

@UniqueMint
Copy link

how do i put the id? is it ownerID = ['590390033626824754'] ?

@WorldEnd0
Copy link

how do i put the id? is it ownerID = ['590390033626824754'] ?

No. replace 'ownerID' with your id. e.g. '54375923959967537'

@geenva
Copy link

geenva commented Oct 24, 2020

it does not seem to work today.

@notbeer
Copy link

notbeer commented Nov 1, 2020

Instead of

if (message.author.id !== 'ownerID') return;

You can simply do:

if(message.author.id !== message.guild.owner.id) return;

@geenva
Copy link

geenva commented Nov 1, 2020

Instead of

if (message.author.id !== 'ownerID') return;

You can simply do:

if(message.author.id !== message.guild.owner.id) return;

You sure you want to let thousands of users at risk by letting every guild owner run eval, and potentially wreck your server?

@notbeer
Copy link

notbeer commented Nov 1, 2020

Instead of
if (message.author.id !== 'ownerID') return;
You can simply do:
if(message.author.id !== message.guild.owner.id) return;

You sure you want to let thousands of users at risk by letting every guild owner run eval, and potentially wreck your server?

As in for 1 server use i meant my bad

@geenva
Copy link

geenva commented Nov 1, 2020

Instead of
if (message.author.id !== 'ownerID') return;
You can simply do:
if(message.author.id !== message.guild.owner.id) return;

You sure you want to let thousands of users at risk by letting every guild owner run eval, and potentially wreck your server?

As in for 1 server use i meant my bad

That's better. Remember to disable the Public Bot switch.

@brianseminara
Copy link

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment