Skip to content

Context Menus

Context menus are interactions under the hood. Defining them is very similar. Context menus work off ctx.target which contains the object the user interacted with.

You can also define scopes and permissions for them, just like with interactions.

For more information, please visit the API reference here.

Message Context Menus

These open up if you right-click a message and choose Apps.

This example repeats the selected message:

1
2
3
4
5
6
from interactions import ContextMenuContext, Message, message_context_menu

@message_context_menu(name="repeat")
async def repeat(ctx: ContextMenuContext):
    message: Message = ctx.target
    await ctx.send(message.content)

User Context Menus

These open up if you right-click a user and choose Apps.

This example pings the user:

1
2
3
4
5
6
from interactions import user_context_menu, Member

@user_context_menu(name="ping")
async def ping(ctx: ContextMenuContext):
    member: Member = ctx.target
    await ctx.send(member.mention)
Note

Unlike Slash command names, context menu command names can be uppercase, contain special symbols and spaces.