Context Menu Generator
Create user and message context menu commands for your Discord bot. Generate right-click menu code with full customization options.
2-32 characters. This name appears in the right-click menu.
Minimum permissions required to use this command
This is how your context menu command will appear when users right-click on a user.
// Discord.js v14+ - Register Context Menu Command
const { REST, Routes, ApplicationCommandType } = require('discord.js');
const commands = [
{
name: 'Command Name',
type: ApplicationCommandType.User, // 2
// default_member_permissions: null, // Everyone can use
// dm_permission: false,
// nsfw: false,
}
];
const rest = new REST().setToken('YOUR_BOT_TOKEN');
// Register globally (takes up to 1 hour)
await rest.put(
Routes.applicationCommands('YOUR_CLIENT_ID'),
{ body: commands }
);
// Or register to a specific guild (instant)
await rest.put(
Routes.applicationGuildCommands('YOUR_CLIENT_ID', 'YOUR_GUILD_ID'),
{ body: commands }
);// Discord.js v14+ - Handle Context Menu Interaction
client.on('interactionCreate', async (interaction) => {
if (!interaction.isContextMenuCommand()) return;
if (interaction.commandName === 'Command Name') {
// Get the user that was right-clicked
const targetUser = interaction.targetUser;
const targetMember = interaction.targetMember;
// Example: Show user info
await interaction.reply({
content: `User: ${targetUser.tag}\nID: ${targetUser.id}\nCreated: <t:${Math.floor(targetUser.createdTimestamp / 1000)}:R>`,
ephemeral: true
});
}
});What are Context Menu Commands?
Context menu commands (also called message commands or user commands) appear when right-clicking on users or messages. They provide quick actions without requiring slash command syntax.
What are Context Menu Commands?
Context menu commands (also called application commands) appear when users right-click (or tap and hold on mobile) on users or messages in Discord. They provide quick actions without requiring users to type slash commands.
Context menu commands are perfect for actions that target specific users or messages, such as viewing profiles, translating messages, reporting content, or moderating users.
Command Types
User Commands
Appear when right-clicking on a user's profile, avatar, or username. The command receives the targeted user as a parameter.
- • View detailed user information
- • Show user's avatar in full size
- • Moderate user (timeout, kick, ban)
- • Add user to a list or database
- • Check user's server join date
Message Commands
Appear when right-clicking on a message. The command receives the targeted message as a parameter with full content and metadata.
- • Translate message to another language
- • Report message to moderators
- • Quote and reply to message
- • Add message to starboard
- • Bookmark message for later
How Users Access Context Menus
Desktop
- 1. Right-click on a user or message
- 2. Hover over "Apps" in the context menu
- 3. Click your custom command
Mobile
- 1. Long-press on a user or message
- 2. Tap "Apps"
- 3. Select your custom command
Registering Context Menu Commands
Context menu commands must be registered with Discord before they can be used:
Global Registration
Commands are available in all servers where your bot is installed.
- • Takes up to 1 hour to propagate
- • Recommended for production bots
- • Limited to 100 global commands
Guild-Specific Registration
Commands are only available in a specific server.
- • Updates instantly (no delay)
- • Perfect for testing and development
- • Limited to 100 commands per guild
Popular Context Menu Commands
Avatar
User CommandDisplay a user's avatar in full resolution with download link.
Translate
Message CommandTranslate a message to the user's preferred language using an API.
Report User
User CommandAllow users to report problematic members to moderators privately.
Bookmark
Message CommandSave important messages to a private bookmark list for later reference.
Setting Permissions
You can restrict who can use context menu commands using default member permissions:
Everyone can use the command. Best for utility commands like Avatar or User Info.
Only members with timeout permissions. Good for moderation commands.
Only server administrators. Use for sensitive operations like ban or server configuration.
Best Practices
Use Clear Command Names
Keep names short (2-32 characters) and descriptive. Users should understand what the command does just from its name (e.g., "User Info", "Translate", "Report").
Set Appropriate Permissions
Restrict moderation commands to users with proper permissions. Keep utility commands accessible to everyone.
Use Ephemeral Responses
Make responses visible only to the user who triggered the command when appropriate. This prevents spam and keeps channels clean.
Respond Quickly
Discord requires a response within 3 seconds. For longer operations, send an initial
acknowledgment with deferReply() and update later.
Limit Command Count
You can register up to 5 user commands and 5 message commands globally. Choose the most useful commands for your bot's purpose.
Test on Mobile
Context menus work differently on mobile devices. Test your commands on both desktop and mobile to ensure a good user experience.
Handle Errors Gracefully
Always include error handling. If an operation fails, provide a clear error message to the user explaining what went wrong.