Node.js Discord bot that can:
- ✅ display the weather forecast;
- ✅ display the position of sun and moon;
- ✅ tell jokes;
- ✅ inspire you with quotes from different categories;
In our Node app, the Discord Bot will connect to Discord API using discord.js
library through WebSocket connection, and will listen for any commands prompted from the Discord UI. The Bot has defined a set of commands that will run each time a user uses a slash command.
🔗The video tutorial test from Discord client
- Be sure you haveNode.js installed.
- Open a terminal and run
npm install
. - Create a new Discord account if you do not have one.
- Create a Discord server to test the bot, then find the server/guild ID by turning the developer mode.
- Navigate to Discord Developers page and create a new app, then find the application/client ID.
- Invite the bot to your server.
- Sign up to a free Weather API account and find your API key.
- Sign up to a free API Ninjas account and find your API key.
- Create a
.env
file at the root of the project and insert the data as below.
Populate the following values in .env
:
DISCORD_TOKEN=
CLIENT_ID=
GUILD_ID=
WHEATHER_API_KEY=
API_NINJAS_KEY=
- Production script:
npm start
- Development:
npm run dev
- Integrate the bot with AI
- Integrate bot with a music streaming service