Skip to content

Commit

Permalink
docs: some tweaks and intend fixes in code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Commandserver committed Jul 21, 2023
1 parent 22986b2 commit c4eb713
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main()
if (dpp::run_once<struct register_bot_commands>()) {
/* Register the command */
bot.guild_command_create(
dpp::slashcommand()
dpp::slashcommand()
.set_type(dpp::ctxm_user)
.set_name("High Five")
.set_application_id(bot.me.id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,32 @@ something like `dpp::cluster::request()`.
int main()
{
dpp::cluster bot("token");
dpp::cluster bot("token");
bot.on_log(dpp::utility::cout_logger());
bot.on_log(dpp::utility::cout_logger());
bot.on_slashcommand([&bot](const dpp::slashcommand_t & event) {
if (event.command.type == dpp::it_application_command) {
dpp::command_interaction cmd_data = std::get<dpp::command_interaction>(event.command.data);
if (cmd_data.name == "show") {
dpp::snowflake file_id = std::get<dpp::snowflake>(event.get_parameter("file"));
auto iter = event.command.resolved.attachments.find(file_id);
if (iter != event.command.resolved.attachments.end()) {
const dpp::attachment& att = iter->second;
event.reply(att.url);
}
}
}
});
bot.on_slashcommand([&bot](const dpp::slashcommand_t & event) {
dpp::command_interaction cmd_data = std::get<dpp::command_interaction>(event.command.data);
if (cmd_data.name == "show") {
dpp::snowflake file_id = std::get<dpp::snowflake>(event.get_parameter("file"));
dpp::attachment att = event.command.get_resolved_attachment(file_id);
event.reply(att.url);
}
});
bot.on_ready([&bot](const dpp::ready_t & event) {
bot.on_ready([&bot](const dpp::ready_t & event) {
if (dpp::run_once<struct register_bot_commands>()) {
dpp::slashcommand newcommand("show", "Show an uploaded file", bot.me.id);
if (dpp::run_once<struct register_bot_commands>()) {
dpp::slashcommand newcommand("show", "Show an uploaded file", bot.me.id);
newcommand.add_option(dpp::command_option(dpp::co_attachment, "file", "Select an image"));
newcommand.add_option(dpp::command_option(dpp::co_attachment, "file", "Select an image"));
bot.global_command_create(newcommand);
}
});
bot.global_command_create(newcommand);
}
});
bot.start(dpp::st_wait);
bot.start(dpp::st_wait);
return 0;
return 0;
}
~~~~~~~~~~~~~~~~

0 comments on commit c4eb713

Please sign in to comment.