A NodeJS discord bot that does what you need while allowing for your custom JS scripts.
- Clone the repo, run
npm install
to get dependencies - run
npm run start
, this will create necessary json files - Edit data.json and replace TOKEN_HERE with your discord bot token
- From here your bot should be ready to use! Run
npm run start
Commands must always start with $
$help - lists available commands.
$help <command_name> - lists help message for command.
$add <command_name> <reply...> - adds new command.
$set <command_name> <reply...> - overrwrites existing command reply
$del - deletes command
$<custom_command> - runs custom command.
$restart - restarts bot
$sethelp - sets help message for a custom command.
You can have commands that run your very own JS scripts. All scripts are stores within /scripts as .js files. To greet users with a random greeting, we can add the random_greeting.js script in data.json:
See the random greeting script
{
...
"commands": {
"greetme": {
"name": "greetme",
"script": "random_greeting.js"
}
},
...
}
To aid users, you can link it to the help function which will return your help_msg string:
"greetme": {
"name": "greetme",
"script": "random_greeting.js",
"help_msg": "Responds to you with a random greeting :)"
}
If the user types help greetme
the bot will run the script and reply with something like @user123, Nice meeting you!
Normal commands without scripts will look something like this:
"test_command": {
"name": "test_command",
"response": "Hello World!",
"help_msg": "this is a command used for testing."
}