From f3330c47cc7958e09d27d80124c45476069d3162 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 14:50:08 +0500 Subject: [PATCH] Bump Remora.Discord with 5 updates (#346) Bumps the remora group with 5 updates: | Package | From | To | | --- | --- | --- | | [Remora.Discord.Caching](https://github.com/Remora/Remora.Discord) | `39.0.0` | `40.0.0` | | [Remora.Commands](https://github.com/Remora/Remora.Commands) | `10.0.6` | `11.0.1` | | [Remora.Discord.Extensions](https://github.com/Remora/Remora.Discord) | `5.3.6` | `6.0.0` | | [Remora.Discord.Interactivity](https://github.com/Remora/Remora.Discord) | `5.0.0` | `6.0.0` | | [Remora.Discord.Hosting](https://github.com/Remora/Remora.Discord) | `6.0.10` | `7.0.0` | Signed-off-by: dependabot[bot] Signed-off-by: Octol1ttle Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Octol1ttle --- .../Responders/MessageEditedResponder.cs | 31 ++++++------------- .../TeamOctolings.Octobot.csproj | 10 +++--- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/TeamOctolings.Octobot/Responders/MessageEditedResponder.cs b/TeamOctolings.Octobot/Responders/MessageEditedResponder.cs index 2968562..e3d1c58 100644 --- a/TeamOctolings.Octobot/Responders/MessageEditedResponder.cs +++ b/TeamOctolings.Octobot/Responders/MessageEditedResponder.cs @@ -36,40 +36,29 @@ public sealed class MessageEditedResponder : IResponder public async Task RespondAsync(IMessageUpdate gatewayEvent, CancellationToken ct = default) { - if (!gatewayEvent.ID.IsDefined(out var messageId)) - { - return new ArgumentNullError(nameof(gatewayEvent.ID)); - } - - if (!gatewayEvent.ChannelID.IsDefined(out var channelId)) - { - return new ArgumentNullError(nameof(gatewayEvent.ChannelID)); - } - if (!gatewayEvent.GuildID.IsDefined(out var guildId) - || !gatewayEvent.Author.IsDefined(out var author) - || !gatewayEvent.EditedTimestamp.IsDefined(out var timestamp) - || !gatewayEvent.Content.IsDefined(out var newContent)) + || !gatewayEvent.EditedTimestamp.HasValue + || gatewayEvent.Author.IsBot.OrDefault(false)) { return Result.Success; } var cfg = await _guildData.GetSettings(guildId, ct); - if (author.IsBot.OrDefault(false) || GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty()) + if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty()) { return Result.Success; } - var cacheKey = new KeyHelpers.MessageCacheKey(channelId, messageId); + var cacheKey = new KeyHelpers.MessageCacheKey(gatewayEvent.ChannelID, gatewayEvent.ID); var messageResult = await _cacheService.TryGetValueAsync( cacheKey, ct); if (!messageResult.IsDefined(out var message)) { - _ = _channelApi.GetChannelMessageAsync(channelId, messageId, ct); + _ = _channelApi.GetChannelMessageAsync(gatewayEvent.ChannelID, gatewayEvent.ID, ct); return Result.Success; } - if (message.Content == newContent) + if (message.Content == gatewayEvent.Content) { return Result.Success; } @@ -83,22 +72,22 @@ public sealed class MessageEditedResponder : IResponder // We don't need to await this since the result is not needed // NOTE: Because this is not awaited, there may be a race condition depending on how fast clients are able to edit their messages // NOTE: Awaiting this might not even solve this if the same responder is called asynchronously - _ = _channelApi.GetChannelMessageAsync(channelId, messageId, ct); + _ = _channelApi.GetChannelMessageAsync(gatewayEvent.ChannelID, gatewayEvent.ID, ct); - var diff = InlineDiffBuilder.Diff(message.Content, newContent); + var diff = InlineDiffBuilder.Diff(message.Content, gatewayEvent.Content); Messages.Culture = GuildSettings.Language.Get(cfg); var builder = new StringBuilder() .AppendLine(diff.AsMarkdown()) .AppendLine(string.Format(Messages.DescriptionActionJumpToMessage, - $"https://discord.com/channels/{guildId}/{channelId}/{messageId}") + $"https://discord.com/channels/{guildId}/{gatewayEvent.ChannelID}/{gatewayEvent.ID}") ); var embed = new EmbedBuilder() .WithSmallTitle(string.Format(Messages.CachedMessageEdited, message.Author.GetTag()), message.Author) .WithDescription(builder.ToString()) - .WithTimestamp(timestamp.Value) + .WithTimestamp(gatewayEvent.EditedTimestamp.Value) .WithColour(ColorsList.Yellow) .Build(); diff --git a/TeamOctolings.Octobot/TeamOctolings.Octobot.csproj b/TeamOctolings.Octobot/TeamOctolings.Octobot.csproj index 418803a..b67eaf8 100644 --- a/TeamOctolings.Octobot/TeamOctolings.Octobot.csproj +++ b/TeamOctolings.Octobot/TeamOctolings.Octobot.csproj @@ -27,11 +27,11 @@ - - - - - + + + + +