@moscowcity/djs-eval
This package helps you quickly evaluate any thing via discord.js bot.
- 2 lines setup!
- Multilanguage!
Installation
Package requires Node.js v10+ to run.
Install package using this command:
$ npm install discord-js-eval
Usage
First, declare requirement.
const _eval = require('@moscowcity/djs-eval');
Then create command:
const _evalCommand = new _eval.Eval([ 'owner', 'Ids' ], 'locale');
Only 1 thing left, call 'run' function. 2nd argument
_evalCommand.run(messageObject);
To run with dependencies (client, message, args, etc) use this:
_evalCommand.run(messageObject, {bot: client, etc: 'etc'});
Example eval command
const _eval = require("@moscowcity/djs-eval");
const Eval = new _eval.Eval(["323424226889433088"], "ru");
module.exports.run = async (client, message) => {
Eval.run(message, { bot: 0 });
};
Imagine that message content is:
const moment = require("moment")
moment(Date.now()).format("DD.MM.YYYY HH:mm")
If author id is not the same as specified, output message:
You are not permitted to use this command!
If everything is correct, output message:
06.08.2021 11:47
Included methods
Reply from code with .catch(), or just send callback
use 'doReply()' or 'doReply' in your code.
To make callback with error, use doReply in .catch():
doReply('test');
or
doSomething().then(doSomethingElse()).catch(doReply);
To get all methods of class, use 'getMethods(obj)'
doReply(getMethods(require('@moscowcity/djs-eval')))