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() {
);
);
std::cout << callback.http_info.body << "\n" ;
}
});
});
if(cmd_data.options[0].name == "dog") {
if(cmd_data.options[0].options.size() > 0) {
dpp::snowflake user = std::get<dpp::snowflake>(cmd_data.options[0].options[0].value);
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) {
dpp::snowflake user = std::get<dpp::snowflake>(cmd_data.options[0].options[0].value);
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:392
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:762
slashcommand & add_option(const command_option &o)
Add an option (parameter)
slashcommand & set_description(const std::string &d)
Set the description of the command.
slashcommand & set_name(const std::string &n)
Set the name of the command.
@ co_sub_command
Definition: appcommand.h:49
@ co_user
Definition: appcommand.h:59
Details of a command within an interaction. This subobject represents the application command associa...
Definition: appcommand.h:506
std::vector< command_data_option > options
Optional: the params + values from the user.
Definition: appcommand.h:509
Each command option is a command line parameter. It can have a type (see dpp::command_option_type),...
Definition: appcommand.h:137
The results of a REST call wrapped in a convenient struct.
Definition: cluster.h:193
bool is_error() const
Returns true if the call resulted in an error rather than a legitimate value in the confirmation_call...
Create interaction.
Definition: dispatcher.h:283
interaction command
command interaction
Definition: dispatcher.h:395
Session ready.
Definition: dispatcher.h:601