@ -1,15 +1,22 @@
const Discord = require ( 'discord.js' ) ;
const Discord = require ( 'discord.js' ) ;
const chalk = require ( 'chalk' ) ;
const chalk = require ( 'chalk' ) ;
const { Tag } = require ( '../util/tag' ) ;
const { TagFilter } = require ( '../util/tagfilter' ) ;
module . exports = {
module . exports = {
name : 'eval' ,
name : 'eval' ,
aliases : [ 'ev' , ':' , 'e' ] ,
aliases : [ 'ev' , ':' , 'e' ] ,
help : "Evaluates raw JavaScript code. *This is a __developer-only__ command.* Usage: `{{p}}eval <code>`" ,
help : "Evaluates raw JavaScript code. *This is a __developer-only__ command.* Usage: `{{p}}eval <code>`" ,
execute ( message , msg , args , cmd , prefix , mention , client ) {
execute ( message , msg , args , cmd , prefix , mention , client ) {
try {
try {
if ( ! client . developers . includes ( message . author . id ) ) return ;
if ( ! client . developers . includes ( message . author . id ) ) { return message . channel . send ( "Sorry, but I've got trust issues, so only me devs can go commanding me around like that." ) ; } ;
if ( ! args . length ) return message . channel . send ( ` Syntax: \` ${ prefix } eval <code> \` ` ) ;
if ( ! args . length ) return message . channel . send ( ` Syntax: \` ${ prefix } eval <code> \` ` ) ;
let options = new TagFilter ( [ new Tag ( [ 's' , 'silent' , 'nr' , 'noreply' ] , 'silent' , 'toggle' ) ] ) . test ( args [ 0 ] ) ;
if ( options . silent ) { args . shift ( ) ; }
if ( ! args . length ) { return message . channel . send ( "Silly goose, if you want me to do something, you have to tell me what!" ) ; }
const result = new Promise ( ( resolve ) => resolve ( eval ( args . join ( ' ' ) ) ) ) ;
const result = new Promise ( ( resolve ) => resolve ( eval ( args . join ( ' ' ) ) ) ) ;
return result . then ( ( output ) => {
return result . then ( ( output ) => {
if ( typeof output !== 'string' ) {
if ( typeof output !== 'string' ) {
@ -19,7 +26,7 @@ module.exports = {
. replace ( client . config . database . password , 'Database Password' )
. replace ( client . config . database . password , 'Database Password' )
. replace ( client . config . database . cluster , 'Database Cluster' ) ;
. replace ( client . config . database . cluster , 'Database Cluster' ) ;
return message . channel . send ( new Discord . MessageEmbed ( )
return options . silent ? null : message . channel . send ( new Discord . MessageEmbed ( )
. setTitle ( 'Client Evaluation' )
. setTitle ( 'Client Evaluation' )
. setDescription ( ` \` \` \` js \n ${ output } \n \` \` \` ` )
. setDescription ( ` \` \` \` js \n ${ output } \n \` \` \` ` )
. setColor ( 'c375f0' )
. setColor ( 'c375f0' )