Creating the bot application
Access Discord Developer Portal
- Go to the Discord Developer Portal
- Log in with your Discord account
- Click “New Application” in the top right
- Enter a name for your application (e.g., “Yato Bot”)
- Click “Create”
Configure general information
- On the “General Information” tab, you can:
- Add an app icon
- Write a description
- Add tags
- Copy your Application ID (also called Client ID) and save it as
CLIENT_IDin your.envfile
The Application ID is used for generating invite links and OAuth2 authorization.
Create the bot user
- Click on the “Bot” tab in the left sidebar
- Click “Add Bot”
- Click “Yes, do it!” to confirm
- Customize your bot:
- Set a username
- Upload a bot avatar
- Disable “Public Bot” if you want only you to invite it
Configuring bot intents
Intents define which events your bot receives from Discord. Yato requires specific intents to function properly.What are intents?
Intents control which gateway events Discord sends to your bot. They help Discord scale by reducing unnecessary events sent to bots.Required intents for Yato
Yato was built with discord.js v12, which has different intent requirements than modern versions. The bot currently uses basic client configuration without explicit intents.
Server Members Intent
Enable SERVER MEMBERS INTENT (Privileged)Required for:
- Detecting when members join/leave servers
- Fetching member information for commands
- Welcome messages and member tracking
- User info commands
Message Content Intent
Enable MESSAGE CONTENT INTENT (Privileged)Required for:
- Reading message content for legacy prefix commands
- Message-based command handling
- Content moderation features
Current implementation
Yato’s current client initialization (src/index.js:7):
For modern Discord.js versions (v13+), you should explicitly specify intents:
Bot permissions
Yato requires specific Discord permissions to function properly.Permission calculator
The bot uses permission value1879436407 for its invite link (src/commands/information/botinfo.js:35).
This includes:
| Permission | Description |
|---|---|
| View Channels | See channels to interact in |
| Send Messages | Send messages in text channels |
| Embed Links | Send rich embeds with images and formatting |
| Attach Files | Upload images and files |
| Read Message History | Read previous messages in channels |
| Add Reactions | Add emoji reactions to messages |
| Use External Emojis | Use emojis from other servers |
| Mention @everyone, @here, and All Roles | Mention mass groups (use carefully) |
| Manage Messages | Delete messages (for moderation) |
| Manage Roles | Create, edit, and assign roles |
| Kick Members | Kick members from the server |
| Ban Members | Ban members from the server |
| Manage Channels | Create, edit, and delete channels |
| Use Slash Commands | Use application commands |
Required permissions
Minimum permissions for basic functionality:- View Channels
- Send Messages
- Embed Links
- Read Message History
- Use Slash Commands
Recommended permissions
For full functionality (moderation, role management, etc.):- All basic permissions
- Manage Messages (for purge/moderation)
- Kick Members (for kick command)
- Ban Members (for ban command)
- Manage Roles (for role management)
- Attach Files (for Canvas-generated images)
- Add Reactions (for interactive commands)
Generating invite links
Using Discord Developer Portal
Navigate to OAuth2
- In the Discord Developer Portal, select your application
- Click “OAuth2” in the left sidebar
- Click “URL Generator”
Select permissions
Under “BOT PERMISSIONS”, select the permissions your bot needs.For Yato, you can use the permission integer
1879436407 or select permissions individually.Manual invite URL
You can also construct the invite URL manually:YOUR_CLIENT_ID with your Application ID.
Slash commands setup
Yato uses thegcommands library for slash command handling.
Automatic registration
Slash commands are automatically registered when the bot starts, configured insrc/index.js:15-25:
Configuration options
- cmdDir: Directory containing command files
- slash:
'both'enables both slash commands and mention-based commands - prefix: Regex pattern allowing commands via bot mentions
- defaultCooldown: Prevents command spam (3 seconds between uses)
Development vs. Production
Development: Use
GUILD_ID in .env to register commands to a specific server (instant updates)Production: Omit GUILD_ID to register commands globally (updates take up to 1 hour but work in all servers)Testing your bot
Invite bot to test server
Use your invite link to add the bot to a test Discord server where you have admin permissions.
Test slash commands
In Discord, type
/ in any channel where the bot has access. You should see Yato’s commands in the autocomplete menu.Try:/help- View available commands/botinfo- View bot information/ping- Test bot responsiveness
Common issues
Bot appears offline
Possible causes:- Invalid or expired token
- Bot not invited to server
- Network/firewall blocking Discord connections
- Verify
TOKENin.envis correct - Regenerate token in Developer Portal if needed
- Check bot is in the server’s member list
- Ensure no firewall blocks Discord’s gateway
Slash commands not appearing
Possible causes:- Bot missing
applications.commandsscope - Commands not yet registered globally
- Bot lacks necessary permissions
- Re-invite bot with
applications.commandsscope - For development, add
GUILD_IDto.envfor instant registration - Wait up to 1 hour for global command registration
- Ensure bot has “Use Slash Commands” permission
Bot can’t read messages
Possible causes:- Missing Message Content intent
- Missing “View Channel” or “Read Message History” permissions
- Enable Message Content Intent in Developer Portal
- Grant “View Channels” and “Read Message History” permissions
- Re-invite bot with updated permissions
Permission errors
Error:Missing Permissions
Solutions:
- Ensure bot’s role is high enough in the role hierarchy
- Grant specific permissions in channel or server settings
- Re-invite bot with correct permission integer
- Check bot isn’t trying to moderate members with higher roles
Security best practices
- Never share your bot token: Treat it like a password
- Use minimal permissions: Only grant what’s necessary
- Restrict bot access: Use channel permissions to limit bot visibility
- Implement rate limiting: GCommands includes cooldown protection
- Validate user input: Sanitize user-provided data (especially for Canvas rendering)
- Monitor bot activity: Review logs for suspicious behavior
- Keep dependencies updated: Regularly update discord.js and other libraries
- Disable public bot: If for personal use, disable “Public Bot” setting
Next steps
Now that your Discord bot is set up:- Configure your environment variables
- Set up MongoDB for data persistence
- Deploy your bot to a hosting service
- Explore available commands and features