-
Notifications
You must be signed in to change notification settings - Fork 17
Creating new functions
Creating new functions is fairly easily, just follow this example.
"<name-of-function>": {
name: "<name_of_function_for_help>",
description: "<description>",
extendedhelp: "<more_info>",
adminOnly: <true>,
timeout: <time>,
usage: "<usage-explanation>",
process: function(<operators>) {
bot.<function>;
}
},
<name-of-function> = Enter the name you want your users to execute.
<name_of_function_for_help> = This is the name that will be printed into !help
<description> = Enter a description for your command here, this will not be printed into !help
<more_info> = Enter even more information about the 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.",
name: "ping",
extendedhelp: "I'll reply to you with ping, this way you can see if I'm still able to take commands.",
process: function(bot, msg, suffix) {
bot.sendMessage(msg.channel, " "+msg.sender+" pong!");
if(suffix){
bot.sendMessage(msg.channel, "note that !ping takes no arguments!");
}
}
},