I am open to, and grateful for any contributions made by the community to help develop this discord bot. Please go through this document once before you contribute or open a pull request.
- JavaScript and Node.js
- Puppeteer, Axios, and jsDom for scraping the contest details
- Discord.js for interacting with Discord
- MonogDB as the database
- Moongoose for interacting with MongoDB
- Microsoft Azure for hosting the bot
File or Folder | Use |
---|---|
index.js | Main entry file which initializes everything and starts the bot |
deploy.js | Push all the slash commands to discord |
commands | All the slash commands |
interactions | All the interaction hooks for things like button press, select change etc |
database | The mongo.js contains all the database operations, and the schema folder contains the document schemas |
loops | The contests scraping.js file fetches the latest contest details from various platforms, contest message.js file sends the contest notifications, problem message.js file send the daily problems, and changing activity.js file changes the bot activity every 15 seconds |
utility | The embed message.js file sends or returns embed messages, joining message.js file sends a message on joining a new server |
Clone this repository and install all required dependencies using npm install
A config.json file present in the same location as the index.js file contains all the bot secret configurations and hence not available publicly on this repo. The format is given below. You need to create one and update the following: guildId
, clientIdTest
, tokenTest
, mongourlTest
{
"guildId": "testing_server_id",
"clientIdTest": "testing_bot_id",
"clientIdProd": "production_bot_id",
"tokenTest": "testing_bot_token",
"tokenProd": "production_bot_token",
"mongourlTest": "testing_mongodb_url/db",
"mongourlProd": "production_mongodb_url/db",
"codeforcesKey": "codeforces_api_key",
"codeforcesSecret": "codeforces_api_secret",
"isProduction": false
}
-
Open the Discord Developers Portal.
-
Switch to
Applications
tab and then click theNew Application
button, enter your desired bot name and clickCreate
. -
Switch to
Bot
tab, clickAdd Bot
, and confirmYes, do it!
. Click onReset Token
and copy the new token (this is thetokenTest
for config.json file). -
Switch to
General Information
tab, copy theAPPLICATION ID
(this is theclientIdTest
for config.json file), and invite the bot to your test server using the below link by replacing the{APPLICATION_ID_HERE}
https://discord.com/oauth2/authorize?client_id={APPLICATION_ID_HERE}&permissions=268435456&scope=bot%20applications.commands
-
From the dropdown, you need to choose an existing server from the options.
-
But if there are none to be selected from the dropdown, click on Discord Website. to login or create a discord account. Then Click on the
+
tab on the left menu to add a New Server. -
Switch back to the link below and refresh, from the dropdown select the newly created server.
https://discord.com/oauth2/authorize?client_id={APPLICATION_ID_HERE}&permissions=268435456&scope=bot%20applications.commands
-
When you open your test server on discord, the link will be in the below format. Get the
guildId
from here.https://discord.com/channels/guildId/channelId
-
Setup MongoDB server locally or create a MongoDB Atlas account, and get the connection url (look this up on YouTube as it is beyond the scope of this setup instruction). This will be the
mongourlTest
.
-
Deploy the slash commands once using
node deploy.js
, you will see thisSuccessfully registered server application commands!
if successful. -
Run the bot using
node index.js
this shows up if successfulConnected to MongoDB. Notifications loop started. Daily problem loop started. Scraping loop started. Bot is online.
-
Go back to your discord account, on the chat box type the
/
and choose different files from the commands folder in VS code find a screenshot below. Discord Bot.