{"size": 552, "ext": "js", "max_stars_repo_path": "src/handler/js.js", "max_stars_repo_name": "Xananax/codi-discord-bot", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/handler/js.js", "max_issues_repo_name": "Xananax/codi-discord-bot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/handler/js.js", "max_forks_repo_name": "Xananax/codi-discord-bot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.6666666667, "max_line_length": 119, "alphanum_fraction": 0.5326086957}
const safeEval = require('notevil')

module.exports = {
  allow:()=>true,
  help:()=>`Runs javascript`,
  run:({ reply, args })=> {
    const strings = []
    const context = { log: (...what) => strings.push(what.join(' ')) }
    try{
      const ret = safeEval(args.join(' '),context);
      const result = JSON.stringify({result:ret},null,2)
      const boxed = "```js\n"+result.replace(/`/g,'\`')+(strings.length ? '\nlog:\n'+strings.join('\n') : '')+"\n```\n"
      reply(boxed)
    }catch(e){
      reply('```js\n'+e.message+'\n```\n')
    }
  }
}