diff --git a/src/02_interactions_and_components/01_slash_cmds/02_clearing_registered_cmds/src/main.cpp b/src/02_interactions_and_components/01_slash_cmds/02_clearing_registered_cmds/src/main.cpp index 7b1ccfb..0a82a21 100644 --- a/src/02_interactions_and_components/01_slash_cmds/02_clearing_registered_cmds/src/main.cpp +++ b/src/02_interactions_and_components/01_slash_cmds/02_clearing_registered_cmds/src/main.cpp @@ -1,6 +1,37 @@ +#include +#include +#include +#include + #include int main() { - std::cout << "WIP" << std::endl; + // Load the .env file into the environment + dotenv::init(); + // Make sure the DISCORD_TOKEN env var exists + if (!std::getenv("DISCORD_TOKEN") || !std::getenv("DISCORD_GUILD")) { + std::cout << "Failed to get DISCORD_TOKEN or DISCORD_GUILD from .env or environment" << std::endl; + return 0; + } + // Load in the bot token + std::string botToken = std::getenv("DISCORD_TOKEN"); + // Load in the guild id + std::string guildId = std::getenv("DISCORD_GUILD"); + + // Create the bot + dpp::cluster bot(botToken); + // Register a cout_logger + bot.on_log(dpp::utility::cout_logger()); + + // Create a lambda to be called when the bot is ready + bot.on_ready([&bot, &guildId](const dpp::ready_t& event) { + // Bulk delete any globally registered commands + bot.global_bulk_command_delete(); + // Bulk delete any guild commands registered to the passed in guild id + bot.guild_bulk_command_delete(guildId); + }); + + // Start the bot + bot.start(dpp::st_wait); return 0; }