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>()) {
bot.guild_command_create(
.set_name("High Five")
.set_application_id(bot.me.id),
857692897221033129
);
}
});
dpp::user user = event.get_user();
dpp::user author = event.command.get_issuing_user();
event.reply(author.get_mention() + " slapped " + user.get_mention());
}
});
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:82
std::string get_command_name() const
Get the command name for a command interaction.
Represents an application command, created by your bot either globally, or on a guild.
Definition: appcommand.h:982
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:566
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:65
interaction command
command interaction
Definition: dispatcher.h:488
Session ready.
Definition: dispatcher.h:783
It registers a guild command that can be called by right-click a user and click on the created menu.