forked from TeamInklings/Octobot
Make LogAction return void (#261)
1) the method isn't actually async lulw 2) it always returns success, so might as well just be void reduces complexity by a bit Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
58bd439aa7
commit
d39303560d
6 changed files with 12 additions and 39 deletions
|
@ -196,12 +196,8 @@ public class BanCommandGroup : CommandGroup
|
||||||
title, target)
|
title, target)
|
||||||
.WithColour(ColorsList.Green).Build();
|
.WithColour(ColorsList.Green).Build();
|
||||||
|
|
||||||
var logResult = _utility.LogActionAsync(
|
_utility.LogAction(
|
||||||
data.Settings, channelId, executor, title, description, target, ColorsList.Red, ct: ct);
|
data.Settings, channelId, executor, title, description, target, ColorsList.Red, ct: ct);
|
||||||
if (!logResult.IsSuccess)
|
|
||||||
{
|
|
||||||
return Result.FromError(logResult.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
||||||
}
|
}
|
||||||
|
@ -287,12 +283,9 @@ public class BanCommandGroup : CommandGroup
|
||||||
|
|
||||||
var title = string.Format(Messages.UserUnbanned, target.GetTag());
|
var title = string.Format(Messages.UserUnbanned, target.GetTag());
|
||||||
var description = new StringBuilder().AppendBulletPoint(string.Format(Messages.DescriptionActionReason, reason));
|
var description = new StringBuilder().AppendBulletPoint(string.Format(Messages.DescriptionActionReason, reason));
|
||||||
var logResult = _utility.LogActionAsync(
|
|
||||||
|
_utility.LogAction(
|
||||||
data.Settings, channelId, executor, title, description.ToString(), target, ColorsList.Green, ct: ct);
|
data.Settings, channelId, executor, title, description.ToString(), target, ColorsList.Green, ct: ct);
|
||||||
if (!logResult.IsSuccess)
|
|
||||||
{
|
|
||||||
return Result.FromError(logResult.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,12 +136,8 @@ public class ClearCommandGroup : CommandGroup
|
||||||
return Result.FromError(deleteResult.Error);
|
return Result.FromError(deleteResult.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
var logResult = _utility.LogActionAsync(
|
_utility.LogAction(
|
||||||
data.Settings, channelId, executor, title, description, bot, ColorsList.Red, false, ct);
|
data.Settings, channelId, executor, title, description, bot, ColorsList.Red, false, ct);
|
||||||
if (!logResult.IsSuccess)
|
|
||||||
{
|
|
||||||
return Result.FromError(logResult.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(title, bot)
|
var embed = new EmbedBuilder().WithSmallTitle(title, bot)
|
||||||
.WithColour(ColorsList.Green).Build();
|
.WithColour(ColorsList.Green).Build();
|
||||||
|
|
|
@ -157,12 +157,9 @@ public class KickCommandGroup : CommandGroup
|
||||||
|
|
||||||
var title = string.Format(Messages.UserKicked, target.GetTag());
|
var title = string.Format(Messages.UserKicked, target.GetTag());
|
||||||
var description = MarkdownExtensions.BulletPoint(string.Format(Messages.DescriptionActionReason, reason));
|
var description = MarkdownExtensions.BulletPoint(string.Format(Messages.DescriptionActionReason, reason));
|
||||||
var logResult = _utility.LogActionAsync(
|
|
||||||
|
_utility.LogAction(
|
||||||
data.Settings, channelId, executor, title, description, target, ColorsList.Red, ct: ct);
|
data.Settings, channelId, executor, title, description, target, ColorsList.Red, ct: ct);
|
||||||
if (!logResult.IsSuccess)
|
|
||||||
{
|
|
||||||
return Result.FromError(logResult.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(
|
var embed = new EmbedBuilder().WithSmallTitle(
|
||||||
string.Format(Messages.UserKicked, target.GetTag()), target)
|
string.Format(Messages.UserKicked, target.GetTag()), target)
|
||||||
|
|
|
@ -153,12 +153,8 @@ public class MuteCommandGroup : CommandGroup
|
||||||
.AppendBulletPoint(string.Format(
|
.AppendBulletPoint(string.Format(
|
||||||
Messages.DescriptionActionExpiresAt, Markdown.Timestamp(until))).ToString();
|
Messages.DescriptionActionExpiresAt, Markdown.Timestamp(until))).ToString();
|
||||||
|
|
||||||
var logResult = _utility.LogActionAsync(
|
_utility.LogAction(
|
||||||
data.Settings, channelId, executor, title, description, target, ColorsList.Red, ct: ct);
|
data.Settings, channelId, executor, title, description, target, ColorsList.Red, ct: ct);
|
||||||
if (!logResult.IsSuccess)
|
|
||||||
{
|
|
||||||
return Result.FromError(logResult.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(
|
var embed = new EmbedBuilder().WithSmallTitle(
|
||||||
string.Format(Messages.UserMuted, target.GetTag()), target)
|
string.Format(Messages.UserMuted, target.GetTag()), target)
|
||||||
|
@ -339,12 +335,9 @@ public class MuteCommandGroup : CommandGroup
|
||||||
|
|
||||||
var title = string.Format(Messages.UserUnmuted, target.GetTag());
|
var title = string.Format(Messages.UserUnmuted, target.GetTag());
|
||||||
var description = MarkdownExtensions.BulletPoint(string.Format(Messages.DescriptionActionReason, reason));
|
var description = MarkdownExtensions.BulletPoint(string.Format(Messages.DescriptionActionReason, reason));
|
||||||
var logResult = _utility.LogActionAsync(
|
|
||||||
|
_utility.LogAction(
|
||||||
data.Settings, channelId, executor, title, description, target, ColorsList.Green, ct: ct);
|
data.Settings, channelId, executor, title, description, target, ColorsList.Green, ct: ct);
|
||||||
if (!logResult.IsSuccess)
|
|
||||||
{
|
|
||||||
return Result.FromError(logResult.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(
|
var embed = new EmbedBuilder().WithSmallTitle(
|
||||||
string.Format(Messages.UserUnmuted, target.GetTag()), target)
|
string.Format(Messages.UserUnmuted, target.GetTag()), target)
|
||||||
|
|
|
@ -218,12 +218,8 @@ public class SettingsCommandGroup : CommandGroup
|
||||||
var title = Messages.SettingSuccessfullyChanged;
|
var title = Messages.SettingSuccessfullyChanged;
|
||||||
var description = builder.ToString();
|
var description = builder.ToString();
|
||||||
|
|
||||||
var logResult = _utility.LogActionAsync(
|
_utility.LogAction(
|
||||||
data.Settings, channelId, executor, title, description, bot, ColorsList.Magenta, false, ct);
|
data.Settings, channelId, executor, title, description, bot, ColorsList.Magenta, false, ct);
|
||||||
if (!logResult.IsSuccess)
|
|
||||||
{
|
|
||||||
return Result.FromError(logResult.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(title, bot)
|
var embed = new EmbedBuilder().WithSmallTitle(title, bot)
|
||||||
.WithDescription(description)
|
.WithDescription(description)
|
||||||
|
|
|
@ -196,7 +196,7 @@ public sealed class Utility
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="ct">The cancellation token for this operation.</param>
|
/// <param name="ct">The cancellation token for this operation.</param>
|
||||||
/// <returns>A result which has succeeded.</returns>
|
/// <returns>A result which has succeeded.</returns>
|
||||||
public Result LogActionAsync(
|
public void LogAction(
|
||||||
JsonNode cfg, Snowflake channelId, IUser user, string title, string description, IUser avatar,
|
JsonNode cfg, Snowflake channelId, IUser user, string title, string description, IUser avatar,
|
||||||
Color color, bool isPublic = true, CancellationToken ct = default)
|
Color color, bool isPublic = true, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
|
@ -205,7 +205,7 @@ public sealed class Utility
|
||||||
if (GuildSettings.PublicFeedbackChannel.Get(cfg).EmptyOrEqualTo(channelId)
|
if (GuildSettings.PublicFeedbackChannel.Get(cfg).EmptyOrEqualTo(channelId)
|
||||||
&& GuildSettings.PrivateFeedbackChannel.Get(cfg).EmptyOrEqualTo(channelId))
|
&& GuildSettings.PrivateFeedbackChannel.Get(cfg).EmptyOrEqualTo(channelId))
|
||||||
{
|
{
|
||||||
return Result.FromSuccess();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var logEmbed = new EmbedBuilder().WithSmallTitle(title, avatar)
|
var logEmbed = new EmbedBuilder().WithSmallTitle(title, avatar)
|
||||||
|
@ -230,8 +230,6 @@ public sealed class Utility
|
||||||
privateChannel, embedResult: logEmbed,
|
privateChannel, embedResult: logEmbed,
|
||||||
ct: ct);
|
ct: ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.FromSuccess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Result<Snowflake>> GetEmergencyFeedbackChannel(IGuild guild, GuildData data, CancellationToken ct)
|
public async Task<Result<Snowflake>> GetEmergencyFeedbackChannel(IGuild guild, GuildData data, CancellationToken ct)
|
||||||
|
|
Reference in a new issue