This is how to use Subcommands within your Slash Commands for your bots.
#include <dpp/dpp.h>
#include <dpp/fmt/format.h>
#include <iostream>
int main() {
if (dpp::run_once<struct register_bot_commands>()) {
image.add_option(
);
image.add_option(
);
std::cout << callback.http_info.body << "\n" ;
}
});
}
});
if (cmd_data.
options[0].name ==
"dog") {
if (cmd_data.
options[0].options.size() > 0) {
event.reply(fmt::format("<@{}> has now been turned into a dog.", user));
} else {
event.reply("<A picture of a dog.>");
}
}
if (cmd_data.
options[0].name ==
"cat") {
if (cmd_data.
options[0].options.size() > 0) {
event.reply(fmt::format("<@{}> has now been turned into a cat.", user));
} else {
event.reply("<A picture of a cat.>");
}
}
}
});
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:469
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:810
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
uint64_t snowflake
A 64 bit unsigned value representing many things on discord. Discord calls the value a 'snowflake' va...
Definition: snowflake.h:32
@ co_sub_command
Definition: appcommand.h:50
@ co_user
Definition: appcommand.h:60
Details of a command within an interaction. This subobject represents the application command associa...
Definition: appcommand.h:538
std::vector< command_data_option > options
Optional: the params + values from the user.
Definition: appcommand.h:541
Each command option is a command line parameter. It can have a type (see dpp::command_option_type),...
Definition: appcommand.h:150
The results of a REST call wrapped in a convenient struct.
Definition: cluster.h:238
bool is_error() const
Returns true if the call resulted in an error rather than a legitimate value in the confirmation_call...
interaction command
command interaction
Definition: dispatcher.h:488
Session ready.
Definition: dispatcher.h:783
User has issued a slash command.
Definition: dispatcher.h:499