Skip to content

Commit

Permalink
docs: added a page for clearing slashcommands (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskowicz1 authored Oct 11, 2023
1 parent a5ba94e commit d6fd83d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
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

0 comments on commit d6fd83d

Please sign in to comment.