Skip to main content
Before running Yato, you need to create a Discord bot application and configure it with the necessary permissions and intents.

Creating the bot application

1

Access Discord Developer Portal

  1. Go to the Discord Developer Portal
  2. Log in with your Discord account
  3. Click “New Application” in the top right
  4. Enter a name for your application (e.g., “Yato Bot”)
  5. Click “Create”
2

Configure general information

  1. On the “General Information” tab, you can:
    • Add an app icon
    • Write a description
    • Add tags
  2. Copy your Application ID (also called Client ID) and save it as CLIENT_ID in your .env file
The Application ID is used for generating invite links and OAuth2 authorization.
3

Create the bot user

  1. Click on the “Bot” tab in the left sidebar
  2. Click “Add Bot”
  3. Click “Yes, do it!” to confirm
  4. Customize your bot:
    • Set a username
    • Upload a bot avatar
    • Disable “Public Bot” if you want only you to invite it
4

Get your bot token

  1. Under the “TOKEN” section, click “Reset Token”
  2. Click “Yes, do it!” to confirm
  3. Click “Copy” to copy the token
  4. Save this token as TOKEN in your .env file
Your bot token is sensitive information. Never share it publicly or commit it to version control. If compromised, regenerate it immediately.

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.
In the Discord Developer Portal, under the “Bot” tab, enable these Privileged Gateway Intents:
1

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
2

Message Content Intent

Enable MESSAGE CONTENT INTENT (Privileged)Required for:
  • Reading message content for legacy prefix commands
  • Message-based command handling
  • Content moderation features
As of September 2022, this is a privileged intent required for bots to read message content. Without it, message content will appear empty for non-slash commands.
3

Presence Intent (Optional)

Enable PRESENCE INTENT (Privileged) if you want:
  • Member status tracking (online, idle, etc.)
  • Custom status information
  • Activity tracking
This is optional for Yato’s core functionality but may be required for certain features.

Current implementation

Yato’s current client initialization (src/index.js:7):
const client = new Discord.Client({ 
  allowedMentions: { parse: ['users', 'roles'] } 
});
For modern Discord.js versions (v13+), you should explicitly specify intents:
const { Client, GatewayIntentBits } = require('discord.js');

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent
  ],
  allowedMentions: { parse: ['users', 'roles'] }
});

Bot permissions

Yato requires specific Discord permissions to function properly.

Permission calculator

The bot uses permission value 1879436407 for its invite link (src/commands/information/botinfo.js:35). This includes:
PermissionDescription
View ChannelsSee channels to interact in
Send MessagesSend messages in text channels
Embed LinksSend rich embeds with images and formatting
Attach FilesUpload images and files
Read Message HistoryRead previous messages in channels
Add ReactionsAdd emoji reactions to messages
Use External EmojisUse emojis from other servers
Mention @everyone, @here, and All RolesMention mass groups (use carefully)
Manage MessagesDelete messages (for moderation)
Manage RolesCreate, edit, and assign roles
Kick MembersKick members from the server
Ban MembersBan members from the server
Manage ChannelsCreate, edit, and delete channels
Use Slash CommandsUse application commands

Required permissions

Minimum permissions for basic functionality:
  • View Channels
  • Send Messages
  • Embed Links
  • Read Message History
  • Use Slash Commands
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)

Using Discord Developer Portal

1

Navigate to OAuth2

  1. In the Discord Developer Portal, select your application
  2. Click “OAuth2” in the left sidebar
  3. Click “URL Generator”
2

Select scopes

Under “SCOPES”, select:
  • bot
  • applications.commands
3

Select permissions

Under “BOT PERMISSIONS”, select the permissions your bot needs.For Yato, you can use the permission integer 1879436407 or select permissions individually.
4

Copy and use invite URL

  1. Copy the generated URL at the bottom
  2. Paste it in your browser
  3. Select a server to add the bot to
  4. Click “Authorize”

Manual invite URL

You can also construct the invite URL manually:
https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=1879436407&scope=bot%20applications.commands
Replace YOUR_CLIENT_ID with your Application ID.
https://discord.com/api/oauth2/authorize?client_id=123456789012345678&permissions=1879436407&scope=bot%20applications.commands
Avoid using Administrator permission in production. Only grant the specific permissions your bot needs.

Slash commands setup

Yato uses the gcommands library for slash command handling.

Automatic registration

Slash commands are automatically registered when the bot starts, configured in src/index.js:15-25:
const GCommandsClient = new GCommands(client, {
  cmdDir: 'src/commands/',
  language: 'english',
  ownLanguageFile: require('./config/message.json'),
  unkownCommandMessage: true,
  slash: {
    slash: 'both',
    prefix: `^<@!?${client.user.id}> `
  },
  defaultCooldown: '3s'
});

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

1

Invite bot to test server

Use your invite link to add the bot to a test Discord server where you have admin permissions.
2

Start the bot

Run the bot locally:
npm run dev
# or
node src/index.js
You should see:
➤ Logged in as YourBot#1234 (123456789012345678)
✔ Connected to MongoDB
3

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
4

Test mention commands

You can also use commands by mentioning the bot:
@YourBot help

Common issues

Bot appears offline

Possible causes:
  • Invalid or expired token
  • Bot not invited to server
  • Network/firewall blocking Discord connections
Solutions:
  • Verify TOKEN in .env is 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.commands scope
  • Commands not yet registered globally
  • Bot lacks necessary permissions
Solutions:
  • Re-invite bot with applications.commands scope
  • For development, add GUILD_ID to .env for 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
Solutions:
  • 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

Follow these security guidelines:
  • 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:
  1. Configure your environment variables
  2. Set up MongoDB for data persistence
  3. Deploy your bot to a hosting service
  4. Explore available commands and features

Build docs developers (and LLMs) love