-
Notifications
You must be signed in to change notification settings - Fork 18
Creating new functions
Creating new functions is fairly easily, just follow this example.
"<name-of-function>": {
description: "<description>",
adminOnly: <true>,
timeout: <time>,
usage: "<usage-explanation>",
process: function(<operators>) {
bot.<function>;
}
},
<name-of-function>
= Enter the name you want your users to execute.
<description>
= Enter a description for your command here, this will be printed into !help
<usage>
= If your command needs a suffix, describe it here, this will also be printed into !help
<function>
= This is where you enter the code for the bot to execute, check the wiki from Discord.js for all of the functions the bot can execute.
adminOnly
= Set this to true if you want to restrict this command to administrators, if you don't want this, remove this variable.
timeout
= Define a timeout in seconds here, if you don't want a timeout, remove this variable.
<operators>
= Enter the needed operators for the command here, the operators are:
-
bot
, This operator is always needed. -
msg
, This operator is needed when the bot needs to send or receive a message. -
suffix
, This operator is needed when the command can take a suffix.
Going with this example, here is the code for the !ping
command.
"ping": {
description: "Responds pong, useful for checking if bot is alive.",
process: function(bot, msg, suffix) {
bot.sendMessage(msg.channel, msg.sender+" pong!");
if(suffix){
bot.sendMessage(msg.channel, "note that !ping takes no arguments!");
}
}
},