From 6d1e8c2e02fa2f051f1360d5207b1c18290bff48 Mon Sep 17 00:00:00 2001 From: xs2237 Date: Fri, 22 Mar 2024 00:29:14 +0900 Subject: [PATCH] Remove unnecessary whitespaces at the end of reactions in PlainText (#1213) --- .../Exporting/PlainTextMessageWriter.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs b/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs index 38206ac5..85b46a64 100644 --- a/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/PlainTextMessageWriter.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using DiscordChatExporter.Core.Discord.Data; using DiscordChatExporter.Core.Discord.Data.Embeds; +using DiscordChatExporter.Core.Utils.Extensions; namespace DiscordChatExporter.Core.Exporting; @@ -172,18 +173,21 @@ internal class PlainTextMessageWriter(Stream stream, ExportContext context) await _writer.WriteLineAsync("{Reactions}"); - foreach (var reaction in reactions) + foreach (var (reaction, i) in reactions.WithIndex()) { cancellationToken.ThrowIfCancellationRequested(); + if (i > 0) + { + await _writer.WriteAsync(' '); + } + await _writer.WriteAsync(reaction.Emoji.Name); if (reaction.Count > 1) { await _writer.WriteAsync($" ({reaction.Count})"); } - - await _writer.WriteAsync(' '); } await _writer.WriteLineAsync();