From 9a23e1d5337e0232686feaef34cbb789b06cfe74 Mon Sep 17 00:00:00 2001
From: Macintxsh <95250141+mctaylors@users.noreply.github.com>
Date: Sun, 17 Dec 2023 18:44:18 +0300
Subject: [PATCH] FeedbackServiceExtensions: Add FeedbackMessageOptions support
 (#219)

Required for #218
---
 src/Commands/AboutCommandGroup.cs                |  2 +-
 src/Commands/BanCommandGroup.cs                  | 10 +++++-----
 src/Commands/ClearCommandGroup.cs                |  4 ++--
 .../Events/ErrorLoggingPostExecutionEvent.cs     |  2 +-
 src/Commands/KickCommandGroup.cs                 |  6 +++---
 src/Commands/MuteCommandGroup.cs                 | 16 ++++++++--------
 src/Commands/PingCommandGroup.cs                 |  2 +-
 src/Commands/RemindCommandGroup.cs               | 12 +++++-------
 src/Commands/SettingsCommandGroup.cs             | 12 ++++++------
 src/Commands/ToolsCommandGroup.cs                |  8 ++++----
 src/Extensions/FeedbackServiceExtensions.cs      |  6 ++++--
 11 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/src/Commands/AboutCommandGroup.cs b/src/Commands/AboutCommandGroup.cs
index e491470..45077e6 100644
--- a/src/Commands/AboutCommandGroup.cs
+++ b/src/Commands/AboutCommandGroup.cs
@@ -99,6 +99,6 @@ public class AboutCommandGroup : CommandGroup
             .WithImageUrl("https://cdn.mctaylors.ru/octobot-banner.png")
             .Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 }
diff --git a/src/Commands/BanCommandGroup.cs b/src/Commands/BanCommandGroup.cs
index 3f89819..7493505 100644
--- a/src/Commands/BanCommandGroup.cs
+++ b/src/Commands/BanCommandGroup.cs
@@ -117,7 +117,7 @@ public class BanCommandGroup : CommandGroup
             var failedEmbed = new EmbedBuilder().WithSmallTitle(Messages.UserAlreadyBanned, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var interactionResult
@@ -132,7 +132,7 @@ public class BanCommandGroup : CommandGroup
             var errorEmbed = new EmbedBuilder().WithSmallTitle(interactionResult.Entity, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(errorEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(errorEmbed, ct: ct);
         }
 
         var builder = new StringBuilder().AppendBulletPointLine(string.Format(Messages.DescriptionActionReason, reason));
@@ -190,7 +190,7 @@ public class BanCommandGroup : CommandGroup
             return Result.FromError(logResult.Error);
         }
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     /// <summary>
@@ -255,7 +255,7 @@ public class BanCommandGroup : CommandGroup
             var errorEmbed = new EmbedBuilder().WithSmallTitle(Messages.UserNotBanned, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(errorEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(errorEmbed, ct: ct);
         }
 
         var unbanResult = await _guildApi.RemoveGuildBanAsync(
@@ -281,6 +281,6 @@ public class BanCommandGroup : CommandGroup
             return Result.FromError(logResult.Error);
         }
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 }
diff --git a/src/Commands/ClearCommandGroup.cs b/src/Commands/ClearCommandGroup.cs
index 8e1f90d..7ebd4ea 100644
--- a/src/Commands/ClearCommandGroup.cs
+++ b/src/Commands/ClearCommandGroup.cs
@@ -121,7 +121,7 @@ public class ClearCommandGroup : CommandGroup
             var failedEmbed = new EmbedBuilder().WithSmallTitle(Messages.NoMessagesToClear, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var title = author is not null
@@ -146,6 +146,6 @@ public class ClearCommandGroup : CommandGroup
         var embed = new EmbedBuilder().WithSmallTitle(title, bot)
             .WithColour(ColorsList.Green).Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 }
diff --git a/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs b/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs
index 426fd35..2d5f606 100644
--- a/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs
+++ b/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs
@@ -65,6 +65,6 @@ public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
             .WithColour(ColorsList.Red)
             .Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 }
diff --git a/src/Commands/KickCommandGroup.cs b/src/Commands/KickCommandGroup.cs
index f2a840d..1ef6057 100644
--- a/src/Commands/KickCommandGroup.cs
+++ b/src/Commands/KickCommandGroup.cs
@@ -104,7 +104,7 @@ public class KickCommandGroup : CommandGroup
             var embed = new EmbedBuilder().WithSmallTitle(Messages.UserNotFoundShort, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(embed, CancellationToken);
+            return await _feedback.SendContextualEmbedResultAsync(embed, ct: CancellationToken);
         }
 
         return await KickUserAsync(executor, target, reason, guild, channelId, data, bot, CancellationToken);
@@ -126,7 +126,7 @@ public class KickCommandGroup : CommandGroup
             var failedEmbed = new EmbedBuilder().WithSmallTitle(interactionResult.Entity, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var dmChannelResult = await _userApi.CreateDMAsync(target.ID, ct);
@@ -171,6 +171,6 @@ public class KickCommandGroup : CommandGroup
                 string.Format(Messages.UserKicked, target.GetTag()), target)
             .WithColour(ColorsList.Green).Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 }
diff --git a/src/Commands/MuteCommandGroup.cs b/src/Commands/MuteCommandGroup.cs
index 2ce06ae..6a28f38 100644
--- a/src/Commands/MuteCommandGroup.cs
+++ b/src/Commands/MuteCommandGroup.cs
@@ -101,7 +101,7 @@ public class MuteCommandGroup : CommandGroup
             var embed = new EmbedBuilder().WithSmallTitle(Messages.UserNotFoundShort, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(embed, CancellationToken);
+            return await _feedback.SendContextualEmbedResultAsync(embed, ct: CancellationToken);
         }
 
         return await MuteUserAsync(executor, target, reason, duration, guildId, data, channelId, bot, CancellationToken);
@@ -124,7 +124,7 @@ public class MuteCommandGroup : CommandGroup
             var failedEmbed = new EmbedBuilder().WithSmallTitle(interactionResult.Entity, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var until = DateTimeOffset.UtcNow.Add(duration); // >:)
@@ -151,7 +151,7 @@ public class MuteCommandGroup : CommandGroup
                 string.Format(Messages.UserMuted, target.GetTag()), target)
             .WithColour(ColorsList.Green).Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     private async Task<Result> SelectMuteMethodAsync(
@@ -202,7 +202,7 @@ public class MuteCommandGroup : CommandGroup
                 .WithDescription(Messages.DurationRequiredForTimeOuts)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var muteResult = await _guildApi.ModifyGuildMemberAsync(
@@ -266,7 +266,7 @@ public class MuteCommandGroup : CommandGroup
             var embed = new EmbedBuilder().WithSmallTitle(Messages.UserNotFoundShort, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(embed, CancellationToken);
+            return await _feedback.SendContextualEmbedResultAsync(embed, ct: CancellationToken);
         }
 
         return await RemoveMuteAsync(executor, target, reason, guildId, data, channelId, bot, CancellationToken);
@@ -289,7 +289,7 @@ public class MuteCommandGroup : CommandGroup
             var failedEmbed = new EmbedBuilder().WithSmallTitle(interactionResult.Entity, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var guildMemberResult = await _guildApi.GetGuildMemberAsync(guildId, target.ID, ct);
@@ -307,7 +307,7 @@ public class MuteCommandGroup : CommandGroup
             var failedEmbed = new EmbedBuilder().WithSmallTitle(Messages.UserNotMuted, bot)
                 .WithColour(ColorsList.Red).Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var removeMuteRoleAsync =
@@ -337,7 +337,7 @@ public class MuteCommandGroup : CommandGroup
                 string.Format(Messages.UserUnmuted, target.GetTag()), target)
             .WithColour(ColorsList.Green).Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     private async Task<Result> RemoveMuteRoleAsync(
diff --git a/src/Commands/PingCommandGroup.cs b/src/Commands/PingCommandGroup.cs
index 84b15a0..31fa6dc 100644
--- a/src/Commands/PingCommandGroup.cs
+++ b/src/Commands/PingCommandGroup.cs
@@ -97,6 +97,6 @@ public class PingCommandGroup : CommandGroup
             .WithCurrentTimestamp()
             .Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 }
diff --git a/src/Commands/RemindCommandGroup.cs b/src/Commands/RemindCommandGroup.cs
index 1966b9b..67e7910 100644
--- a/src/Commands/RemindCommandGroup.cs
+++ b/src/Commands/RemindCommandGroup.cs
@@ -85,7 +85,7 @@ public class RemindCommandGroup : CommandGroup
                 .WithColour(ColorsList.Red)
                 .Build();
 
-            return _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var builder = new StringBuilder();
@@ -104,8 +104,7 @@ public class RemindCommandGroup : CommandGroup
             .WithColour(ColorsList.Cyan)
             .Build();
 
-        return _feedback.SendContextualEmbedResultAsync(
-            embed, ct);
+        return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     /// <summary>
@@ -172,7 +171,7 @@ public class RemindCommandGroup : CommandGroup
             .WithFooter(string.Format(Messages.ReminderPosition, memberData.Reminders.Count))
             .Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     /// <summary>
@@ -215,7 +214,7 @@ public class RemindCommandGroup : CommandGroup
                 .WithColour(ColorsList.Red)
                 .Build();
 
-            return _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var reminder = data.Reminders[index];
@@ -231,7 +230,6 @@ public class RemindCommandGroup : CommandGroup
             .WithColour(ColorsList.Green)
             .Build();
 
-        return _feedback.SendContextualEmbedResultAsync(
-            embed, ct);
+        return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 }
diff --git a/src/Commands/SettingsCommandGroup.cs b/src/Commands/SettingsCommandGroup.cs
index 60323d7..a8891bd 100644
--- a/src/Commands/SettingsCommandGroup.cs
+++ b/src/Commands/SettingsCommandGroup.cs
@@ -124,7 +124,7 @@ public class SettingsCommandGroup : CommandGroup
                 .WithColour(ColorsList.Red)
                 .Build();
 
-            return _feedback.SendContextualEmbedResultAsync(errorEmbed, ct);
+            return _feedback.SendContextualEmbedResultAsync(errorEmbed, ct: ct);
         }
 
         footer.Append($"{Messages.Page} {page}/{totalPages} ");
@@ -149,7 +149,7 @@ public class SettingsCommandGroup : CommandGroup
             .WithFooter(footer.ToString())
             .Build();
 
-        return _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     /// <summary>
@@ -207,7 +207,7 @@ public class SettingsCommandGroup : CommandGroup
                 .WithColour(ColorsList.Red)
                 .Build();
 
-            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+            return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
         }
 
         var builder = new StringBuilder();
@@ -230,7 +230,7 @@ public class SettingsCommandGroup : CommandGroup
             .WithColour(ColorsList.Green)
             .Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     /// <summary>
@@ -284,7 +284,7 @@ public class SettingsCommandGroup : CommandGroup
             .WithColour(ColorsList.Green)
             .Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     private async Task<Result> ResetAllSettingsAsync(JsonNode cfg, IUser bot,
@@ -305,6 +305,6 @@ public class SettingsCommandGroup : CommandGroup
             .WithColour(ColorsList.Green)
             .Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 }
diff --git a/src/Commands/ToolsCommandGroup.cs b/src/Commands/ToolsCommandGroup.cs
index be4c2c1..78058cb 100644
--- a/src/Commands/ToolsCommandGroup.cs
+++ b/src/Commands/ToolsCommandGroup.cs
@@ -163,7 +163,7 @@ public class ToolsCommandGroup : CommandGroup
             .WithFooter($"ID: {target.ID.ToString()}")
             .Build();
 
-        return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     private static Color AppendGuildInformation(Color color, IGuildMember guildMember, StringBuilder builder)
@@ -312,7 +312,7 @@ public class ToolsCommandGroup : CommandGroup
             .WithFooter($"ID: {guild.ID.ToString()}")
             .Build();
 
-        return _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     /// <summary>
@@ -389,7 +389,7 @@ public class ToolsCommandGroup : CommandGroup
             .WithColour(embedColor)
             .Build();
 
-        return _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 
     private static readonly TimestampStyle[] AllStyles =
@@ -459,6 +459,6 @@ public class ToolsCommandGroup : CommandGroup
             .WithColour(ColorsList.Blue)
             .Build();
 
-        return _feedback.SendContextualEmbedResultAsync(embed, ct);
+        return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
     }
 }
diff --git a/src/Extensions/FeedbackServiceExtensions.cs b/src/Extensions/FeedbackServiceExtensions.cs
index 739aa34..40e0d53 100644
--- a/src/Extensions/FeedbackServiceExtensions.cs
+++ b/src/Extensions/FeedbackServiceExtensions.cs
@@ -1,4 +1,5 @@
 using Remora.Discord.API.Objects;
+using Remora.Discord.Commands.Feedback.Messages;
 using Remora.Discord.Commands.Feedback.Services;
 using Remora.Results;
 
@@ -7,13 +8,14 @@ namespace Octobot.Extensions;
 public static class FeedbackServiceExtensions
 {
     public static async Task<Result> SendContextualEmbedResultAsync(
-        this IFeedbackService feedback, Result<Embed> embedResult, CancellationToken ct = default)
+        this IFeedbackService feedback, Result<Embed> embedResult,
+        FeedbackMessageOptions? options = null, CancellationToken ct = default)
     {
         if (!embedResult.IsDefined(out var embed))
         {
             return Result.FromError(embedResult);
         }
 
-        return (Result)await feedback.SendContextualEmbedAsync(embed, ct: ct);
+        return (Result)await feedback.SendContextualEmbedAsync(embed, options, ct);
     }
 }