Last active
August 6, 2022 20:20
-
-
Save Lewdcario/c457c12f7eabfb4115c2067d634d549a to your computer and use it in GitHub Desktop.
Discord.js sample eval command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice