Discord Bot Written in JavaScript with the Node.js platform using ECMAScript Modules.
- Node.js
- NPM
$ npm install
$ touch settings.json
Warning: this file should never be put in versionning or disclosed.
{
"token": "yourbottoken"
}
Where yourbottoken
is the token you copied from your Developer Portal's application bot.
$ npm start
- Import the file system Node.js built-in module
- Import the Discord JavaScript library
- Read the content of the configuration file as raw text and then
- Handle any configuration reading errors
- Parse the content of the configuration file as JSON
- Handle any parse errors
- Initialize the Discord client with the wanted intents
- Listen for when the bot is ready
- Login with the token
- Listen for when a message is sent
- Listen for when an error occurred
- Handle any login errors