diff --git a/docpages/example_programs/interactions_and_components/context_menus.md b/docpages/example_programs/interactions_and_components/context_menus.md index c48d518388..11f9f105d6 100644 --- a/docpages/example_programs/interactions_and_components/context_menus.md +++ b/docpages/example_programs/interactions_and_components/context_menus.md @@ -4,7 +4,7 @@ Context menus are application commands that appear on the context menu (right cl \image html context_menu_user_command.png -\note This example sets the command as the type dpp::ctxm_user which can only be used by right clicking on a user. To make it appear on a message, you'll want to switch the type to dpp::ctxm_message. +\note This example sets the command as the type dpp::ctxm_user which can only be used by right clicking on a user. To make it appear on a message, you'll want to switch the type to dpp::ctxm_message and listen for the on_message_context_menu (dpp::message_context_menu_t) event. The following example shows how to create and handle **user context menus** for message context menus, read the notice above. @@ -22,12 +22,13 @@ int main() if (dpp::run_once()) { /* Create the command */ - dpp::slashcommand command("High Five", "Send a High Five!", bot.me.id); - + dpp::slashcommand command; + command.set_name("High Five"); + command.set_application_id(bot.me.id); command.set_type(dpp::ctxm_user); /* Register the command */ - bot.guild_command_create(command, guild_id); + bot.guild_command_create(command, 857692897221033129); /* Replace this with the guild id you want */ } }); @@ -50,4 +51,4 @@ int main() It registers a guild command that can be called by right-click a user and click on the created menu. -\image html context_menu_user_command_showcase.png +\image html context_menu_user_command_showcase.png \ No newline at end of file diff --git a/docpages/example_programs/interactions_and_components/upload_parameter.md b/docpages/example_programs/interactions_and_components/upload_parameter.md index 19deaa3a57..0ed39a8bd6 100644 --- a/docpages/example_programs/interactions_and_components/upload_parameter.md +++ b/docpages/example_programs/interactions_and_components/upload_parameter.md @@ -42,6 +42,7 @@ int main() /* Add a parameter option. */ newcommand.add_option(dpp::command_option(dpp::co_attachment, "file", "Select an image")); + /* Register the command */ bot.global_command_create(newcommand); } }); @@ -50,4 +51,4 @@ int main() return 0; } -~~~~~~~~~~~~~~~~ \ No newline at end of file +~~~~~~~~~~~~~~~~ diff --git a/docpages/example_programs/music_and_audio/join_voice.md b/docpages/example_programs/music_and_audio/join_voice.md index 8a44f40f81..2e0920e64f 100644 --- a/docpages/example_programs/music_and_audio/join_voice.md +++ b/docpages/example_programs/music_and_audio/join_voice.md @@ -17,18 +17,22 @@ int main(int argc, char const *argv[]) bot.on_log(dpp::utility::cout_logger()); /* The event is fired when someone issues your commands */ - bot.on_slashcommand([&bot, &fd](const dpp::slashcommand_t& event) { + bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) { /* Check which command they ran */ if (event.command.get_command_name() == "join") { /* Get the guild */ dpp::guild* g = dpp::find_guild(event.command.guild_id); + + /* Get the voice channel that the bot is currently in from this server (will return nullptr if we're not in a voice channel!) */ auto current_vc = event.from->get_voice(event.command.guild_id); bool join_vc = true; - if (!current_vc) { + /* Are we in a voice channel? If so, let's see if we're in the right channel. */ + if (current_vc) { + /* Find the channel id that the user is currently in */ auto users_vc = g->voice_members.find(event.command.get_issuing_user().id); if (users_vc != g->voice_members.end() && current_vc->channel_id == users_vc->second.channel_id) { @@ -39,10 +43,10 @@ int main(int argc, char const *argv[]) * current_vc->send_audio_raw(...) */ } else { - /* We are on a different voice channel. Leave it, then join the new one + /* We are on a different voice channel. We should leave it, then join the new one * by falling through to the join_vc branch below. */ - event.from->disconnect_voice(event.channel.guild_id); + event.from->disconnect_voice(event.command.guild_id); join_vc = true; } @@ -51,6 +55,8 @@ int main(int argc, char const *argv[]) /* If we need to join a vc at all, join it here if join_vc == true */ if(join_vc) { /* Attempt to connect to a voice channel, returns false if we fail to connect. */ + + /* The user issuing the command is not on any voice channel, we can't do anything */ if (!g->connect_member_voice(event.command.get_issuing_user().id)) { event.reply("You don't seem to be in a voice channel!"); return; @@ -87,4 +93,4 @@ int main(int argc, char const *argv[]) return 0; } -~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~ \ No newline at end of file