![]() |
|
[Node.JS] [Discord.js Bot Guide] - Step-by-Step Tutorial w/ Moderation Commands - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183) +---- Thread: [Node.JS] [Discord.js Bot Guide] - Step-by-Step Tutorial w/ Moderation Commands (/showthread.php?tid=6305039) |
[Discord.js Bot Guide] - Step-by-Step Tutorial w/ Moderation Commands - Vectura - Aug 5, 2025 π€ [Discord.js Bot Guide] - Step-by-Step Tutorial w/ Moderation Commands Perfect for beginners. Works in private & public servers! π REQUIREMENTS β’ Node.js β https://nodejs.org β’ Code Editor (e.g. Visual Studio Code β https://code.visualstudio.com) β’ Discord account β https://discord.com π STEP 1β4: CREATE BOT IN DISCORD DEVELOPER PORTAL 1. Go to: https://discord.com/developers/applications 2. Click "New Application" β Give it a name β Click "Create" 3. On the left: Go to "Bot" β Click "Add Bot" β Confirm 4. Under Privileged Gateway Intents: Enable: - SERVER MEMBERS - MESSAGE CONTENT π STEP 5β6: SETUP TOKENS & PERMISSIONS 5. Copy your Bot Token (youβll need it later). Also copy Client ID. 6. Generate bot invite link (replace YOUR_CLIENT_ID): Bot Invite Link π» STEP 7β10: LOCAL SETUP 7. Create folder "mybot" and open terminal inside it 8. Run: npm init -y 9. Then run: npm install discord.js@14 dotenv 10. Create files: β’ index.js β’ .env β Add: BOT_TOKEN=your_token_here π STEP 11β13: BASIC BOT CODE [index.js] Code require('dotenv').config();π¬ STEP 14β16: BASIC COMMANDS Add inside your file: Code client.on('messageCreate', msg => {π‘οΈ STEP 17β21: MODERATION COMMANDS Add more commands below: Code // Kickπ¦ STEP 22: START YOUR BOT LOCALLY After youβve written your code, itβs time to run your bot for the first time! In your terminal, inside the βmybotβ folder, run: Code node index.jsIf everything is set up correctly, youβll see this in your terminal: Code β
Logged in as YourBotName#1234π‘ Keep your terminal open to keep your bot online. To stop the bot, press CTRL + C. π§ STEP 23β26: EXTRA TIPS 23. Create a βMutedβ role in your server with no send permissions in channels 24. You can expand with commands like !unmute, !userinfo, !serverinfo, etc. 25. Use .env to hide secrets β NEVER commit it to GitHub! 26. Host your bot on Repl.it, Glitch, Heroku or use VPS for 24/7 uptime β YOUR BOT IS READY! Join your server, type !ping or !kick @user and youβre good to go. Feel free to share your bot invite with friends or keep it private. In the next tutorial I'll go into more detail about slash commands, for example, or leave your suggestions in the comments, and who knows, I might work them out for you! RE: [Discord.js Bot Guide] - Step-by-Step Tutorial w/ Moderation Commands - xclouded1 - Aug 5, 2025 Really HQ tutorial, I've never created a Discord server, but this looks good! RE: [Discord.js Bot Guide] - Step-by-Step Tutorial w/ Moderation Commands - Vectura - Aug 5, 2025 (Aug 5, 2025 03:42 PM)xclouded1 Wrote: Really HQ tutorial, I've never created a Discord server, but this looks good! Thanks bud! RE: [Discord.js Bot Guide] - Step-by-Step Tutorial w/ Moderation Commands - HerrWinston - Aug 5, 2025 Was a good read, i like .js aswell, i just cant learn it right now, but once i will try that out, this Thread will come in handy :) |