Context menus are application commands that appear on the context menu (right click or tap) of users or messages to perform context-specific actions. They can be created using dpp::slashcommand
. Once you create a context menu, try right-clicking either a user or message to see it in your server!
The following example shows how to create and handle user context menus.
#include <dpp/dpp.h>
#include <iostream>
int main()
{
if (dpp::run_once<struct register_bot_commands>()) {
.set_application_id(bot.me.id);
bot.guild_command_create(command, 857692897221033129);
}
});
if (cmd_data.name == "High Five") {
dpp::user user = event.command.resolved.users.begin()->second;
dpp::user author = event.command.usr;
event.reply(author.get_mention() + " slapped " + user.get_mention());
}
}
});
bot.start(false);
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:447
Represents an application command, created by your bot either globally, or on a guild.
Definition: appcommand.h:781
slashcommand & set_name(const std::string &n)
Set the name of the command.
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ ctxm_user
Add command to user context menu.
Definition: appcommand.h:503
Details of a command within an interaction. This subobject represents the application command associa...
Definition: appcommand.h:512
slashcommand_contextmenu_type type
type of the command interaction
Definition: appcommand.h:516
Create interaction.
Definition: dispatcher.h:291
Session ready.
Definition: dispatcher.h:609
It registers a guild command that can be called by right-click a user and click on the created menu.