A modular discord bot.
!help prints out a help page.
!hello Responds with Hello world!.
!db key=value to set a value in the database.
!db-json json_obj where json_obj will replace current object.
any message Responds with 🎉 with a probability of 0.01%
!r expr Responds with a rendered version of expr using http://asciimath.org/.
Run container in current console window.
docker run -it --rm -e "DISCORD_BOT_TOKEN=yourtokenhere" froadus/kiwi-discord
Run container in detatched mode and always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted.
docker run -d --restart always -e "DISCORD_BOT_TOKEN=yourtokenhere" froadus/kiwi-discord
Register your bot at https://discordapp.com/developers/applications/.
-
Clone the git repo.
-
Install Node.js version > 12.12.0.
-
Type
npm installinappdir. This will install required dependencies. -
Create a new file
app/settings.jsonand paste the following{ "DISCORD_BOT_TOKEN": "paste your token for development bot here" }NOTE:
settings.jsonwill not be commited to this repository. -
Start the bot by typing
node bot.jsinappdir.
Modules can be stored in three ways:
- Single file module in
app/modulesdirectory. For example:app/modules/somemodule.js. - Alternatively, this file can be renamed
index.jsand be placed in a subdirectory calledsomemodule. For exampleapp/modules/somemodule/index.jspoints to the same file as above. - (Deprecated) Lastly, a module (stored as in alt. 2) can be published to npm. Then it can be installed with
npm i somemodule. Notice that with this method this module will not be visible in themodulesdirectory as it is installed in thenode_modulesdirectory instead.
A file named HelloWorldModule.js is the module in this example:
module.exports = class HelloWorldModule {
ready(bot, client) {
bot.onCommand(this.COMMAND, (textMessage, discordMessage) => {
discordMessage.channel.send(this.TEXT);
});
}
help() {
return [`!**${this.COMMAND}** Responds with \`${this.TEXT}\`.`];
}
}Your modules.json should look like this:
[
{
"NAME": "HelloWorldModule",
"COMMAND": "hello",
"TEXT": "Hello world!"
}
]