From e85358337100129d53fd0c9d883002ea7707d17e Mon Sep 17 00:00:00 2001 From: Eveldee Date: Mon, 28 Nov 2022 23:32:18 +0100 Subject: [PATCH] [Raid] Add test message commands --- Cocotte/Modules/Raids/RaidModule.cs | 2 +- Cocotte/Modules/Raids/RaidModuleDebug.cs | 53 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 Cocotte/Modules/Raids/RaidModuleDebug.cs diff --git a/Cocotte/Modules/Raids/RaidModule.cs b/Cocotte/Modules/Raids/RaidModule.cs index b318395..da1ac1a 100644 --- a/Cocotte/Modules/Raids/RaidModule.cs +++ b/Cocotte/Modules/Raids/RaidModule.cs @@ -10,7 +10,7 @@ namespace Cocotte.Modules.Raids; [Group("raid", "Raid related commands")] [SuppressMessage("Performance", "CA1822:Mark members as static")] -public class RaidModule : InteractionModuleBase +public partial class RaidModule : InteractionModuleBase { private readonly ILogger _logger; private readonly IRaidsRepository _raids; diff --git a/Cocotte/Modules/Raids/RaidModuleDebug.cs b/Cocotte/Modules/Raids/RaidModuleDebug.cs new file mode 100644 index 0000000..b24709c --- /dev/null +++ b/Cocotte/Modules/Raids/RaidModuleDebug.cs @@ -0,0 +1,53 @@ +using Cocotte.Utils; +using Discord; +using Discord.Interactions; + +namespace Cocotte.Modules.Raids; + +#if DEBUG +public partial class RaidModule +{ + + [MessageCommand("Add dps")] + public async Task AddDps(IMessage message) + { + await AddTestPlayer(message, PlayerRole.Dps); + } + + [MessageCommand("Add tank")] + public async Task AddTank(IMessage message) + { + await AddTestPlayer(message, PlayerRole.Tank); + } + + [MessageCommand("Add healer")] + public async Task AddHealer(IMessage message) + { + await AddTestPlayer(message, PlayerRole.Healer); + } + + private async Task AddTestPlayer(IMessage message, PlayerRole playerRole) + { + if (message is IUserMessage userMessage && userMessage.Author.IsBot) + { + if (_raids.TryGetRaid(userMessage.Id, out var raid)) + { + raid.AddPlayer(new RosterPlayer( + (ulong) Random.Shared.NextInt64(), + $"Player{Random.Shared.Next(1, 100)}", + playerRole, + (uint) (1000 * Random.Shared.Next(30, 60)), + Random.Shared.Next(0, 2) == 0) + ); + + await UpdateRaidRosterEmbed(raid); + } + } + + await RespondAsync( + embed: EmbedUtils.SuccessEmbed($"Successfully added a {playerRole} player").Build(), + ephemeral: true + ); + } +} +#endif \ No newline at end of file