feat: guild ban add/remove logging, store banned systems in database
This commit is contained in:
parent
ca99bdfb94
commit
8e030acaf3
12 changed files with 227 additions and 36 deletions
|
|
@ -150,15 +150,19 @@ public static class DiscordExtensions
|
|||
return filterByIds != null ? sorted.Where(r => filterByIds.Contains(r.ID)) : sorted;
|
||||
}
|
||||
|
||||
public static async Task<string> TryFormatModeratorAsync(
|
||||
public static async Task<string> TryFormatUserAsync(
|
||||
this UserCache userCache,
|
||||
AuditLogCache.ActionData actionData
|
||||
Snowflake userId,
|
||||
bool addMention = true
|
||||
)
|
||||
{
|
||||
var moderator = await userCache.GetUserAsync(actionData.ModeratorId);
|
||||
return moderator != null
|
||||
? $"{moderator.Tag()} <@{moderator.ID}>"
|
||||
: $"*(unknown user {actionData.ModeratorId}) <@{actionData.ModeratorId}>*";
|
||||
var user = await userCache.GetUserAsync(userId);
|
||||
if (addMention)
|
||||
return user != null
|
||||
? $"{user.Tag()} <@{user.ID}>"
|
||||
: $"*(unknown user {userId}) <@{userId}>*";
|
||||
|
||||
return user != null ? user.Tag() : $"*(unknown user {userId})*";
|
||||
}
|
||||
|
||||
public static int TextLength(this IEmbed embed)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,12 @@ namespace Catalogger.Backend.Extensions;
|
|||
public static class TimeExtensions
|
||||
{
|
||||
public static string Prettify(this TimeSpan timespan, TimeUnit minUnit = TimeUnit.Minute) =>
|
||||
timespan.Humanize(minUnit: minUnit, precision: 5, collectionSeparator: null);
|
||||
timespan.Humanize(
|
||||
maxUnit: TimeUnit.Year,
|
||||
minUnit: minUnit,
|
||||
precision: 5,
|
||||
collectionSeparator: null
|
||||
);
|
||||
|
||||
public static string Prettify(this Duration duration, TimeUnit minUnit = TimeUnit.Minute) =>
|
||||
duration.ToTimeSpan().Prettify(minUnit);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue