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
});
}
});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.