1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00

FeedbackServiceExtensions: Add FeedbackMessageOptions support (#219)

Required for #218
This commit is contained in:
Macintxsh 2023-12-17 18:44:18 +03:00 committed by GitHub
parent b284ac28d5
commit 9a23e1d533
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 40 deletions

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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(

View file

@ -97,6 +97,6 @@ public class PingCommandGroup : CommandGroup
.WithCurrentTimestamp()
.Build();
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}