#include <dpp/dpp.h>
int main() {
dpp::message m{"Test"};
std::string id{event.command.id.str()};
);
event.from->creator->on_button_click.when([&id](const dpp::button_click_t &b) { return b.custom_id == id; }),
event.from->creator->co_sleep(5)
};
if (result.index() == 0) {
event.edit_original_response(
dpp::message{
"You clicked the button with the id " + click_event.
custom_id});
} else {
event.edit_original_response(
dpp::message{
"I haven't got all day!"});
}
}
});
if (dpp::run_once<struct register_bot_commands>()) {
bot.global_command_create(command);
}
});
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:82
event_router_t< log_t > on_log
Called when a log message is to be written to the log. You can attach any logging system here you wis...
Definition: cluster.h:464
Represents the component object. A component is a clickable button or drop down list within a discord...
Definition: message.h:221
component & set_id(const std::string &id)
Set the id of the component. For action rows, this field is ignored. Setting the id will auto-set the...
component & set_label(const std::string &label)
Set the label of the component, e.g. button text. For action rows, this field is ignored....
component & set_type(component_type ct)
Set the type of the component. Button components (type dpp::cot_button) should always be contained wi...
component & add_component(const component &c)
Add a sub-component, only valid for action rows. Adding subcomponents to a component will automatical...
std::string get_command_name() const
Get the command name for a command interaction.
snowflake id
Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID,...
Definition: managed.h:39
Represents an application command, created by your bot either globally, or on a guild.
Definition: appcommand.h:999
Experimental class to co_await on a bunch of awaitable objects, resuming when the first one completes...
Definition: when_any.h:132
constexpr const char m[]
Definition: unicode_emoji.h:5117
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:65
@ cot_button
Clickable button.
Definition: message.h:42
void reply(command_completion_event_t callback=utility::log_error()) const
Acknowledge interaction without displaying a message to the user, for use with button and select menu...
interaction command
command interaction
Definition: dispatcher.h:643
dpp::async< dpp::confirmation_callback_t > co_reply() const
Acknowledge interaction without displaying a message to the user, for use with button and select menu...
Extremely light coroutine object designed to send off a coroutine to execute on its own....
Definition: job.h:46
Represents messages sent and received on Discord.
Definition: message.h:1212
Session ready.
Definition: dispatcher.h:898
User has issued a slash command.
Definition: dispatcher.h:660