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" ;
}
});
});
dpp::command_interaction cmd_data = std::get<dpp::command_interaction>(event.command.data);
if(cmd_data.name == "image") {
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(dpp::ir_channel_message_with_source, fmt::format("<@{}> has now been turned into a dog.", user));
} else {
event.reply(dpp::ir_channel_message_with_source, "<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(dpp::ir_channel_message_with_source, fmt::format("<@{}> has now been turned into a cat.", user));
} else {
event.reply(dpp::ir_channel_message_with_source, "<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:233
uint8_t type
the type of interaction
Definition: slashcommand.h:426
Represents an application command, created by your bot either globally, or on a guild.
Definition: slashcommand.h:525
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.
@ it_application_command
application command (slash command)
Definition: slashcommand.h:353
@ co_sub_command
Definition: slashcommand.h:44
@ co_user
Definition: slashcommand.h:54
Each command option is a command line parameter. It can have a type (see dpp::command_option_type),...
Definition: slashcommand.h:122
The results of a REST call wrapped in a convenient struct.
Definition: cluster.h:173
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:173
interaction command
command interaction
Definition: dispatcher.h:255
Session ready.
Definition: dispatcher.h:432