Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added a page for clearing slashcommands #939

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docpages/example_code/clearing_slashcommands.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <dpp/dpp.h>

int main()
{
dpp::cluster bot("token");

bot.on_log(dpp::utility::cout_logger());

/* We won't be performing any commands, so we don't need to add the event here! */

bot.on_ready([&bot](const dpp::ready_t & event) {
if (dpp::run_once<struct clear_bot_commands>()) {
/* Now, we're going to wipe our commands */
bot.global_bulk_command_delete();
/* This one requires a guild id, otherwise it won't what guild's commands it needs to wipe! */
bot.guild_bulk_command_delete(857692897221033129);
}

/* Because the run_once above uses a 'clear_bot_commands' struct, you can continue to register commands below! */
});

bot.start(dpp::st_wait);

return 0;
}
1 change: 1 addition & 0 deletions docpages/example_programs/interactions_and_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The example programs listed here demonstrate lots of things to do with interactions, application commands (slash commands) and message components. If you're looking to make your bot **modern and user friendly** these examples are what you need.

* \subpage slashcommands "Using Slash Commands and Interactions"
* \subpage clearing_slashcommands
* \subpage subcommands "Slash command sub-commands"
* \subpage user-only-messages "Ephemeral replies ('Only you can see this' replies)"
* \subpage components "Using button components"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\page clearing_slashcommands Clearing registered commands

After a while of creating commands, you may start to wonder "hm, how can I clear these?". Well, this tutorial covers it! All you have to do is simply call dpp::cluster::global_bulk_command_delete or dpp::cluster::guild_bulk_command_delete.

\note Clearing **global commands** will only clear commands that were **made globally**, same goes for the opposite way round. The example will demonstrate using both functions.

\include{cpp} clearing_slashcommands.cpp
Loading