Discord now supports sending auto completion lists for slash command choices. To use this feature you can use code such as the example below:
#include <dpp/dpp.h>
int main()
{
bot.global_command_create(
dpp::slashcommand(
"blep",
"Send a random adorable animal photo", bot.me.id)
)
);
}
});
std::string animal = std::get<std::string>(event.
get_parameter(
"animal"));
event.reply("Blep! You chose " + animal);
}
});
for (auto & opt : event.options) {
if (opt.focused) {
std::string uservalue = std::get<std::string>(opt.value);
);
bot.log(
dpp::ll_debug,
"Autocomplete " + opt.name +
" with value '" + uservalue +
"' in field " + event.
name);
break;
}
}
});
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition cluster.h:89
std::string token
A continuation token for responding to the interaction.
Definition appcommand.h:1078
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:1436
slashcommand & add_option(const command_option &o)
Add an option (parameter)
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
auto run_once()
Run some code within an if() statement only once.
Definition once.h:41
@ ll_debug
Debug.
Definition misc-enum.h:66
@ ir_autocomplete_reply
Reply to autocomplete interaction.
Definition appcommand.h:436
@ co_string
A string value.
Definition appcommand.h:69
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition cluster.h:72
Discord requests that we fill a list of auto completion choices for a command option.
Definition dispatcher.h:856
std::string name
Command name.
Definition dispatcher.h:871
This struct represents choices in a multiple choice option for a command parameter....
Definition appcommand.h:131
Each command option is a command line parameter. It can have a type (see dpp::command_option_type),...
Definition appcommand.h:208
command_option & set_auto_complete(bool autocomp)
Set the auto complete state.
interaction command
command interaction
Definition dispatcher.h:789
virtual command_value get_parameter(const std::string &name) const
Get a slashcommand parameter.
A response to an interaction, used to reply to a command and initiate a message, which can be hidden ...
Definition appcommand.h:468
interaction_response & add_autocomplete_choice(const command_option_choice &achoice)
Add a command option choice.
Session ready.
Definition dispatcher.h:1072
User has issued a slash command.
Definition dispatcher.h:806