Inviting Your Bot
Add your bot to Discord servers
Generate an invite link and add your bot to a server. The invite URL includes scopes (permission categories that define what the bot can do) and specific permissions.
Developer Portal
The simplest way to generate an invite link:
- Open discord.com/developers/applications.
- Select your application.
- Navigate to OAuth2 in the sidebar.
- Under URL Generator, select the
botscope (allows joining servers) andapplications.commandsscope (allows registering slash commands). - Select the permissions your bot requires.
- Copy the generated URL at the bottom.
Discord Developer Portal OAuth2 URL Generator page showing the bot and applications.commands scopes checked, a permissions section with several permission checkboxes selected, and the generated URL at the bottom of the page
CLI Invite
Alternatively, run the invite command:
npx robo inviteThis reads your project configuration, aggregates required permissions from command configs, and outputs a ready-to-use invite URL.
Terminal output from running npx robo invite, showing the generated invite URL with encoded permission bits and scopes, ready to be copied
Permissions and Scopes
The npx robo invite command reads your project's build metadata to determine which permissions your bot needs. During builds, the plugin aggregates permission flags declared in your command configs and stores them in the manifest. The invite CLI then uses that metadata to construct the invite URL with the correct permission bits and scopes (bot and applications.commands by default).
To declare permissions for a command, use createCommandConfig:
import { createCommandConfig } from '@robojs/discordjs'
import { PermissionFlagsBits } from 'discord.js'
export const config = createCommandConfig({
defaultMemberPermissions: PermissionFlagsBits.ManageMessages
})import { createCommandConfig } from '@robojs/discordjs'
import { PermissionFlagsBits } from 'discord.js'
export const config = createCommandConfig({
defaultMemberPermissions: PermissionFlagsBits.ManageMessages
})If you need to customize the invite URL beyond what the CLI generates, use the Developer Portal method described above.
Privileged Intents
Some events require privileged intents that must be enabled in the Discord Developer Portal before your bot can receive them:
- Open your application in the portal.
- Navigate to the Bot tab.
- Scroll to Privileged Gateway Intents.
- Enable the intents your bot needs (Guild Members, Message Content, Presence).
For more detail on how intents work and how the plugin infers them, see the Intents documentation.
Discord Developer Portal Bot tab scrolled to the Privileged Gateway Intents section, showing toggle switches for Presence Intent, Server Members Intent, and Message Content Intent
Troubleshooting
Bot does not appear in the server after inviting
- Check that you selected both the
botandapplications.commandsscopes in the invite URL. - Verify that you have Manage Server permission on the server you are inviting the bot to.
- If the invite link shows "Invalid OAuth2 redirect_uri", regenerate the invite using
npx robo inviteor through the Developer Portal.
Bot is offline after invite
The invite only adds the bot to the server. You still need to run npx robo dev (or npx robo start in production) to bring the bot online. If the bot process is running but appears offline, check that the DISCORD_TOKEN in your .env is correct.
Missing permissions after invite
If the bot cannot perform actions (sending messages, managing roles, etc.), the invite URL may not have included the required permissions. You can either:
- Re-invite the bot with updated permissions using
npx robo invite(the CLI aggregates permissions from your command configs). - Manually adjust the bot's role permissions in Server Settings > Roles.
