This is a basic skeleton for a Discord bot using discordjs, built off of the discordjs guide. This skeleton implements event and command handlers.
- Clone this repository.
- Set the local environment variable
DISCORD_TOKEN
to your Discord bot token (or settoken
inconfig.json
). npm install
.node index.js
.
The bot can be configured via config/bot.js
. The default command prefix is "!".
To add a new event handler, create a directory within events
named after the event you want to catch (full list within the DiscordJS Client object). Every handler must have an index.js
that acts as the entry point to the event. See the existing handler for messages
for an example.
As most Discord bots are reply/response, or execute commands, a default message handler is included. messages/index.js
detects commands with the configured prefix, and parses arguments. It also supports reacting to non-command message events, for i.e. logging or reply/response.
To create a command, export a property type: 'command'
. The bot will check that a message has both the configured prefix, and the correct type
property before executing a command.
If the bot detects a valid command, it returns the message split up into it's command phrase (e.g. args-info) and any arguments that came after the command phrase (e.g. for !args-info 1 2) it would return 1 and 2 as two args
Commands are assumed to be executed in response to user messages, and so are handled by the messages
handler. To add handlers for other events, see Events.
Below is a list of commands provided by default. Want to add a command? Pull requests welcome โจ.
- args-info-command
- Basic away tracking with bot response
- "CTRL"+"C" to shut down the bot through terminal
-
BRB timers
-
Custom reponses