Skip to main content

Context Menus

These application commands are situated under the "Apps" section when you right-click a user or a message. They act like interactions, except they take a User or Message object along with ApplicationCommandInteraction.


Context Menu Introduction


note

For more specific annotations, you can use UserCommandInteraction or MessageCommandInteraction instead of ApplicationCommandInteraction for the respective commands.

User commands

AbhigyanTripsused /User Info
Disnake BotBot05/19/2024
Username: AbhigyanTrips#2474
Bot: False

The function below should have only one required argument, which is an instance of ApplicationCommandInteraction.

@bot.user_command(name="User Info")
async def avatar(inter: disnake.ApplicationCommandInteraction, user: disnake.User):
await inter.response.send_message(f"Username: {user}\nBot: {user.bot}")

Message commands

AbhigyanTripsused /Reverse
Disnake BotBot05/19/2024
.desrever si egassem sihT

The function below should have only one required argument, which is an instance of ApplicationCommandInteraction.

@bot.message_command(name="Reverse")
async def reverse(inter: disnake.ApplicationCommandInteraction, message: disnake.Message):
# Reversing the message and sending it back.
await inter.response.send_message(message.content[::-1])

Context menu notes

  • Context menu commands cannot have subcommands or any other options.
  • Responses to context menu commands and their permissions function the same as slash commands.