From 66060b3048d60668c3b03e37ccec91e4b204c15b Mon Sep 17 00:00:00 2001 From: Pythonic-Rainbow Date: Mon, 18 Mar 2024 13:42:06 +0000 Subject: [PATCH] Use lambda --- Bot/Discord/Dc.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Bot/Discord/Dc.cs b/Bot/Discord/Dc.cs index 1b01260..87a6f6b 100644 --- a/Bot/Discord/Dc.cs +++ b/Bot/Discord/Dc.cs @@ -81,23 +81,19 @@ static string ProcessViolator(Violator v) private static async Task DonationsChangedAsync(IEnumerable> donDelta, IEnumerable> recDelta) { string msg = "[DNT] "; - string[] donItems = new string[donDelta.Count()]; - for (int i = 0; i < donDelta.Count(); i++) + msg += string.Join(", ", donDelta.Select(t => { - (string tag, int donated) = donDelta.ElementAt(i); + (string tag, int donated) = t; string name = Coc.GetMember(tag).Name; - donItems[i] = $"{name}: {donated}"; - } - msg += string.Join(", ", donItems); + return $"{name}: {donated}"; + })); msg += "\n=> "; - string[] recItems = new string[recDelta.Count()]; - for (int i = 0; i < recDelta.Count(); i++) + msg += string.Join(", ", recDelta.Select(t => { - (string tag, int received) = recDelta.ElementAt(i); + (string tag, int received) = t; string name = Coc.GetMember(tag).Name; - recItems[i] = $"{name}: {received}"; - } - msg += string.Join(", ", recItems); + return $"{name}: {received}"; + })); await s_botLog.SendMessageAsync(msg); }