Skip to main content

Context Menus

When you right-click a message, you may see an option called "Apps". Hover over it and you can see commands a bot can run with that message. These are called message commands.

When you right-click a message in the user list, you can once again see an option called "Apps". Hover over it and you can see commands a bot can run with that message. These are called user commands.

Together, these two are called Context Menus or Context Menu Commands. These commands work very much like normal commands, except they take a member or message.

User Commands

Creating a user command is very simple.

@bot.user_command(name="Account Creation Date", guild_ids=[...])  # create a user command for the supplied guilds
async def account_creation_date(ctx, member: discord.Member): # user commands return the member
await ctx.respond(f"{member.name}'s account was created on {member.created_at}")
BobDotComused Account Creation Date
RobocordBot06/27/2022
BobDotCom's account was created on 2020-01-01

Message Commands

@bot.message_command(name="Get Message ID")  # creates a global message command. use guild_ids=[] to create guild-specific commands.
async def get_message_id(ctx, message: discord.Message): # message commands return the message
await ctx.respond(f"Message ID: `{message.id}`")
BobDotCom06/27/2022
Do. Or do not. There is no try.
Other Guide Manused Get Message ID
RobocordBot06/27/2022
Message ID: 930650407917748286