feat: member avatar/name logging, timeout logging
This commit is contained in:
parent
c906a4d6b6
commit
d445b5ba44
10 changed files with 350 additions and 17 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System.Drawing;
|
||||
using Humanizer;
|
||||
using OneOf;
|
||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||
using Remora.Discord.API.Abstractions.Objects;
|
||||
using Remora.Discord.API.Abstractions.Rest;
|
||||
using Remora.Discord.API.Objects;
|
||||
|
|
@ -35,6 +36,40 @@ public static class DiscordExtensions
|
|||
return $"https://cdn.discordapp.com/embed/avatars/{avatarIndex}.png?size={size}";
|
||||
}
|
||||
|
||||
public static string? AvatarUrl(this IGuildMemberUpdate member, int size = 256) =>
|
||||
GuildAvatarUrl(
|
||||
member.GuildID,
|
||||
member.User.ID,
|
||||
member.Avatar.OrDefault()?.Value,
|
||||
isAnimated: member.Avatar.OrDefault()?.HasGif,
|
||||
size
|
||||
);
|
||||
|
||||
public static string? AvatarUrl(this IGuildMember member, Snowflake guildId, int size = 256) =>
|
||||
GuildAvatarUrl(
|
||||
guildId,
|
||||
member.User.GetOrThrow().ID,
|
||||
member.Avatar.OrDefault()?.Value,
|
||||
isAnimated: member.Avatar.OrDefault()?.HasGif,
|
||||
size
|
||||
);
|
||||
|
||||
private static string? GuildAvatarUrl(
|
||||
Snowflake guildId,
|
||||
Snowflake userId,
|
||||
string? hash,
|
||||
bool? isAnimated,
|
||||
int size = 256
|
||||
)
|
||||
{
|
||||
if (hash == null)
|
||||
return null;
|
||||
|
||||
var ext = isAnimated == true ? ".gif" : ".webp";
|
||||
|
||||
return $"https://cdn.discordapp.com/guilds/{guildId}/users/{userId}/avatars/{hash}{ext}?size={size}";
|
||||
}
|
||||
|
||||
public static string? IconUrl(this IGuild guild, int size = 256)
|
||||
{
|
||||
if (guild.Icon == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue