From 7522eb32035979565daf1640ea89d49002920566 Mon Sep 17 00:00:00 2001 From: Manu <52102823+Manu098vm@users.noreply.github.com> Date: Tue, 19 Nov 2024 23:51:49 +0100 Subject: [PATCH] Fix CA2021 --- .../Commands/Management/BotModule.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/SysBot.Pokemon.Discord/Commands/Management/BotModule.cs b/SysBot.Pokemon.Discord/Commands/Management/BotModule.cs index cb4cbd57..a180301d 100644 --- a/SysBot.Pokemon.Discord/Commands/Management/BotModule.cs +++ b/SysBot.Pokemon.Discord/Commands/Management/BotModule.cs @@ -1,8 +1,7 @@ -using Discord; +using Discord; using Discord.Commands; using PKHeX.Core; -using System; -using System.Linq; +using System.Text; using System.Threading.Tasks; namespace SysBot.Pokemon.Discord; @@ -15,16 +14,19 @@ namespace SysBot.Pokemon.Discord; public async Task GetStatusAsync() { var me = SysCord.Runner; - var bots = me.Bots.Select(z => z.Bot).OfType().ToArray(); - if (bots.Length == 0) + var sb = new StringBuilder(); + foreach (var bot in me.Bots) + { + if (bot.Bot is not PokeRoutineExecutorBase b) + continue; + sb.AppendLine(GetDetailedSummary(b)); + } + if (sb.Length == 0) { await ReplyAsync("No bots configured.").ConfigureAwait(false); return; } - - var summaries = bots.Select(GetDetailedSummary); - var lines = string.Join(Environment.NewLine, summaries); - await ReplyAsync(Format.Code(lines)).ConfigureAwait(false); + await ReplyAsync(Format.Code(sb.ToString())).ConfigureAwait(false); } private static string GetDetailedSummary(PokeRoutineExecutorBase z)