This demonstrates how to use sub-commands within slash commands. Also shown below is an example of how to get a "resolved" parameter without having to use the cache or an extra API call.
#include <iostream>
auto subcommand = cmd_data.options[0];
if (subcommand.name == "dog") {
if (!subcommand.options.empty()) {
dpp::user user = event.command.get_resolved_user(subcommand.get_value<dpp::snowflake>(0));
event.reply(user.get_mention() + " has now been turned into a dog.");
} else {
event.reply("No user specified");
}
}
else if (subcommand.name ==
"cat") {
if (!subcommand.options.empty()) {
dpp::user user = event.command.get_resolved_user(subcommand.get_value<dpp::snowflake>(0));
event.reply(user.get_mention() + " has now been turned into a cat.");
} else {
event.reply("No user specified");
}
}
}
});
if (dpp::run_once<struct register_bot_commands>()) {
image.add_option(
);
image.add_option(
);
bot.global_command_create(image);
}
});
return 0;
}