1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-05-03 20:49:54 +03:00

Add Color and Public parameters to LogActionAsync

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-07-23 22:23:27 +05:00
parent 27b8f15e3b
commit d6b09125c7
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
5 changed files with 15 additions and 11 deletions

View file

@ -153,7 +153,7 @@ public class BanCommandGroup : CommandGroup {
.WithColour(ColorsList.Green).Build(); .WithColour(ColorsList.Green).Build();
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, target, ct); data.Settings, channelId, user, title, description, target, ColorsList.Red, ct: ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)
return Result.FromError(logResult.Error); return Result.FromError(logResult.Error);
@ -227,7 +227,8 @@ public class BanCommandGroup : CommandGroup {
var title = string.Format(Messages.UserUnbanned, target.GetTag()); var title = string.Format(Messages.UserUnbanned, target.GetTag());
var description = string.Format(Messages.DescriptionActionReason, reason); var description = string.Format(Messages.DescriptionActionReason, reason);
var logResult = _utility.LogActionAsync(data.Settings, channelId, user, title, description, target, ct); var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, target, ColorsList.Green, ct: ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)
return Result.FromError(logResult.Error); return Result.FromError(logResult.Error);

View file

@ -103,7 +103,7 @@ public class ClearCommandGroup : CommandGroup {
return Result.FromError(deleteResult.Error); return Result.FromError(deleteResult.Error);
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, currentUser, ct); data.Settings, channelId, user, title, description, currentUser, ColorsList.Red, false, ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)
return Result.FromError(logResult.Error); return Result.FromError(logResult.Error);

View file

@ -133,7 +133,7 @@ public class KickCommandGroup : CommandGroup {
var title = string.Format(Messages.UserKicked, target.GetTag()); var title = string.Format(Messages.UserKicked, target.GetTag());
var description = string.Format(Messages.DescriptionActionReason, reason); var description = string.Format(Messages.DescriptionActionReason, reason);
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, target, ct); data.Settings, channelId, user, title, description, target, ColorsList.Red, ct: ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)
return Result.FromError(logResult.Error); return Result.FromError(logResult.Error);

View file

@ -125,7 +125,7 @@ public class MuteCommandGroup : CommandGroup {
Messages.DescriptionActionExpiresAt, Markdown.Timestamp(until))).ToString(); Messages.DescriptionActionExpiresAt, Markdown.Timestamp(until))).ToString();
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, target, ct); data.Settings, channelId, user, title, description, target, ColorsList.Red, ct: ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)
return Result.FromError(logResult.Error); return Result.FromError(logResult.Error);
@ -215,7 +215,7 @@ public class MuteCommandGroup : CommandGroup {
var title = string.Format(Messages.UserUnmuted, target.GetTag()); var title = string.Format(Messages.UserUnmuted, target.GetTag());
var description = string.Format(Messages.DescriptionActionReason, reason); var description = string.Format(Messages.DescriptionActionReason, reason);
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, target, ct); data.Settings, channelId, user, title, description, target, ColorsList.Green, ct: ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)
return Result.FromError(logResult.Error); return Result.FromError(logResult.Error);

View file

@ -1,3 +1,4 @@
using System.Drawing;
using System.Text; using System.Text;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using Boyfriend.Data; using Boyfriend.Data;
@ -158,11 +159,13 @@ public class UtilityService : IHostedService {
/// <param name="title">The title for the embed.</param> /// <param name="title">The title for the embed.</param>
/// <param name="description">The description of the embed.</param> /// <param name="description">The description of the embed.</param>
/// <param name="avatar">The user whose avatar will be displayed next to the <paramref name="title" /> of the embed.</param> /// <param name="avatar">The user whose avatar will be displayed next to the <paramref name="title" /> of the embed.</param>
/// <param name="color">The color of the embed.</param>
/// <param name="isPublic">Whether or not the embed should be sent in <see cref="GuildSettings.PublicFeedbackChannel"/></param>
/// <param name="ct">The cancellation token for this operation.</param> /// <param name="ct">The cancellation token for this operation.</param>
/// <returns></returns> /// <returns>A result which has succeeded.</returns>
public Result LogActionAsync( public Result LogActionAsync(
JsonNode cfg, Snowflake channelId, IUser user, string title, string description, IUser avatar, JsonNode cfg, Snowflake channelId, IUser user, string title, string description, IUser avatar,
CancellationToken ct = default) { Color color, bool isPublic = true, CancellationToken ct = default) {
var publicChannel = GuildSettings.PublicFeedbackChannel.Get(cfg); var publicChannel = GuildSettings.PublicFeedbackChannel.Get(cfg);
var privateChannel = GuildSettings.PrivateFeedbackChannel.Get(cfg); var privateChannel = GuildSettings.PrivateFeedbackChannel.Get(cfg);
if (GuildSettings.PublicFeedbackChannel.Get(cfg).EmptyOrEqualTo(channelId) if (GuildSettings.PublicFeedbackChannel.Get(cfg).EmptyOrEqualTo(channelId)
@ -173,7 +176,7 @@ public class UtilityService : IHostedService {
.WithDescription(description) .WithDescription(description)
.WithActionFooter(user) .WithActionFooter(user)
.WithCurrentTimestamp() .WithCurrentTimestamp()
.WithColour(ColorsList.Green) .WithColour(color)
.Build(); .Build();
if (!logEmbed.IsDefined(out var logBuilt)) if (!logEmbed.IsDefined(out var logBuilt))
@ -182,7 +185,7 @@ public class UtilityService : IHostedService {
var builtArray = new[] { logBuilt }; var builtArray = new[] { logBuilt };
// Not awaiting to reduce response time // Not awaiting to reduce response time
if (publicChannel != channelId.Value) if (isPublic && publicChannel != channelId.Value)
_ = _channelApi.CreateMessageAsync( _ = _channelApi.CreateMessageAsync(
publicChannel, embeds: builtArray, publicChannel, embeds: builtArray,
ct: ct); ct: ct);