How to register command for right click - Discord.JS V14

Viewed 29

I want to create a delete command where when you right click on a message, it will show under apps "Delete Message" from my bot. For example, Atlas has a set reminder (which seems useless) function under apps [image.] I would like to create this as a guild command. Also, I would like to know how to use the interaction create with this right-click-context-menu function. Thanks!

1 Answers

To register these commands, you need to set the type of the ApplicationCommand to 1 (or ApplicationCommandType.ChatInput). See the docs.

Everything else should stay the same except the type. You can register these commands the usual way, which is documented in the guide here

Here's a snippet:

// token should be your bot's token
const rest = new REST({ version: '10' }).setToken(token);

(async () => {
    try {
        console.log(`Started refreshing ${commands.length} application (/) commands.`);

        const data = await rest.put(
            Routes.applicationGuildCommands(clientId, guildId),
            // commands should be an array of ApplicationCommands
            { body: commands },
        );

        console.log(`Successfully reloaded ${data.length} application (/) commands.`);
    } catch (error) {
        console.error(error);
    }
})();
Related