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:392
uint8_t type
the type of interaction
Definition: appcommand.h:589
Represents an application command, created by your bot either globally, or on a guild.
Definition: appcommand.h:727
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: appcommand.h:485
@ co_sub_command
Definition: appcommand.h:49
@ co_user
Definition: appcommand.h:59
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:270
interaction command
command interaction
Definition: dispatcher.h:362
Session ready.
Definition: dispatcher.h:568