From 4d3ff23d471dd151eddbeb350602db7e853031a1 Mon Sep 17 00:00:00 2001 From: Larry Date: Fri, 18 Oct 2024 22:16:11 -0600 Subject: [PATCH] Delete global commands on ready. Remove unused using statements --- DiscordPlayerCountBot/Bot/Bot.cs | 17 ++++++++++++++++- DiscordPlayerCountBot/Providers/RconProvider.cs | 4 +--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/DiscordPlayerCountBot/Bot/Bot.cs b/DiscordPlayerCountBot/Bot/Bot.cs index f200a1d..3564547 100644 --- a/DiscordPlayerCountBot/Bot/Bot.cs +++ b/DiscordPlayerCountBot/Bot/Bot.cs @@ -69,7 +69,22 @@ private async Task DiscordClient_Ready() Description = $"This will show the player count for the server: {Information.Name}" }; - await DiscordClient.CreateGlobalApplicationCommandAsync(globalCommand.Build()); + try + { + await DiscordClient.Rest.DeleteAllGlobalCommandsAsync(); + }catch(Exception ex) + { + Error("Failed to delete global commands.", Information.Id.ToString(), ex); + } + + try + { + await DiscordClient.CreateGlobalApplicationCommandAsync(globalCommand.Build()); + } + catch (Exception ex) + { + Error("Failed to apply global commands.", Information.Id.ToString(), ex); + } } public async Task StartAsync(bool shouldStart) diff --git a/DiscordPlayerCountBot/Providers/RconProvider.cs b/DiscordPlayerCountBot/Providers/RconProvider.cs index c7e41ad..39d8222 100644 --- a/DiscordPlayerCountBot/Providers/RconProvider.cs +++ b/DiscordPlayerCountBot/Providers/RconProvider.cs @@ -1,6 +1,4 @@ -using PlayerCountBot.Enums; -using PlayerCountBot.Exceptions; -using PlayerCountBot.Services; +using PlayerCountBot.Exceptions; namespace PlayerCountBot.Providers {