This Discord bot integrates with LeetCode to provide daily challenges, random problems, user information, and more. It uses discord.js
to interact with the Discord API and leetcode-query
to fetch data from LeetCode.
- Daily LeetCode Challenge notification
- Delivers a random LeetCode problem based on difficulty
- Fetches user profile information
- Displays user streak information
- Provides a user-friendly help command
The bot does not use the traditional message command approach; instead, it uses a slash command approach. This means that when you type /
, you will see a list of available commands in the guild. The commands provided by this bot are:
/potd
- Shows the LeetCode Daily Challenge/random <easy/medium/hard>
- Shows a random LeetCode problem/user <username>
- Shows User Info/streak <username>
- Shows user Streak Info/help
- Shows help message/topic
- Shows a list of LeetCode topics to choose from
-
📂 Clone the repository:
git clone https://github.com/your-github-username/leetcode-discord-bot.git
-
📂 Navigate to the project directory:
cd DDoL
-
🛠 Install the dependencies:
npm install
-
🔐 Create a
.env
file in the root directory and add your Discord bot token and channel ID:TOKEN=your-discord-bot-token CHANNEL_ID=your-channel-id DEVELOPER_ID=your-discord-id
-
Create a new application Go to the Discord Developer Portal and create a new application.
-
Configure
OAuth2
🔑 -
In your app's settings, navigate to OAuth2.
- Open the OAuth2 URL Generator and select the bot option.
- Under Bot Permissions, select Administrator.
- Set up the bot
-
Go to the
Bot
section and enable the following gateway intents:Server Members Intent
Message Content Intent
- Get your bot's
TOKEN
🔐 and Create a Discord server
-
Create a new server in Discord and retrieve the
Channel ID
where your bot will operate.
-
Start the bot 🤖:
npm run start
-
Invite the bot to your Discord server using the OAuth2 URL generated from the Discord Developer Portal.
-
Use the commands in any channel the bot has access to.
-
Register slash commands in your guild using
;register guild <your server ID>
. Please don't provide the server ID if you want to register commands in your current guild. -
If you want to register slash commands in all guilds, ignore the 4th step and run
;register global
Contributions are welcome! Please raise an issue with your changes.
We appreciate your contributions! To get involved, follow these simple steps:
-
Fork the repository 🍴
Make a personal copy of the repository. -
Create a new branch 🌿
Start working on your changes in a separate branch for better tracking. -
Make your changes 🛠️
Update the code, fix bugs, or add new features! -
Commit and push your changes 💻
Make sure to include a clear commit message explaining what you’ve done. -
Submit a Pull Request (PR) 🪄
Once you're ready, open a PR for review.
Done! ✅ That's it—thanks for contributing! We’ll review your PR as soon as possible.
This project is licensed under the MIT License. See the LICENSE file for details.