feat: invite create event

This commit is contained in:
sam 2024-10-14 03:12:00 +02:00
parent 5a2bd7388c
commit 72c09b3e08
2 changed files with 76 additions and 5 deletions

View file

@ -150,6 +150,9 @@ public static class DiscordExtensions
return filterByIds != null ? sorted.Where(r => filterByIds.Contains(r.ID)) : sorted;
}
public static string PrettyFormat(this IUser user, bool addMention = true) =>
addMention ? $"{user.Tag()} <@{user.ID}>" : user.Tag();
public static async Task<string> TryFormatUserAsync(
this UserCache userCache,
Snowflake userId,
@ -157,12 +160,10 @@ public static class DiscordExtensions
)
{
var user = await userCache.GetUserAsync(userId);
if (addMention)
return user != null
? $"{user.Tag()} <@{user.ID}>"
: $"*(unknown user {userId}) <@{userId}>*";
if (user != null)
return user.PrettyFormat(addMention);
return user != null ? user.Tag() : $"*(unknown user {userId})*";
return addMention ? $"*(unknown user {userId})* <@{userId}>" : $"*(unknown user {userId})*";
}
public static int TextLength(this IEmbed embed)