feat(bot): allow separate member avatars for proxied messages (#523)

This allows for using one avatar for the member card, and a different
avatar for proxied messages - so that users can set the main avatar to
a "full" version of their avatar, and the "proxy" avatar to a cropped
version.
This commit is contained in:
the iris system
2023-03-02 06:11:35 +13:00
committed by GitHub
parent 7fffb7f65a
commit ccb89f50e9
12 changed files with 138 additions and 49 deletions

View File

@@ -135,7 +135,7 @@ public class EmbedService
// sometimes Discord will just... not return the avatar hash with webhook messages
var avatar = proxiedMessage.Author.Avatar != null
? proxiedMessage.Author.AvatarUrl()
: member.AvatarFor(LookupContext.ByNonOwner);
: member.WebhookAvatarFor(LookupContext.ByNonOwner);
var embed = new EmbedBuilder()
.Author(new Embed.EmbedAuthor($"#{channelName}: {name}", IconUrl: avatar))
.Thumbnail(new Embed.EmbedThumbnail(avatar))
@@ -175,6 +175,7 @@ public class EmbedService
var guildSettings = guild != null ? await _repo.GetMemberGuild(guild.Id, member.Id) : null;
var guildDisplayName = guildSettings?.DisplayName;
var webhook_avatar = guildSettings?.AvatarUrl ?? member.WebhookAvatarFor(ctx) ?? member.AvatarFor(ctx);
var avatar = guildSettings?.AvatarUrl ?? member.AvatarFor(ctx);
var groups = await _repo.GetMemberGroups(member.Id)
@@ -183,7 +184,7 @@ public class EmbedService
.ToListAsync();
var eb = new EmbedBuilder()
.Author(new Embed.EmbedAuthor(name, IconUrl: avatar.TryGetCleanCdnUrl(), Url: $"https://dash.pluralkit.me/profile/m/{member.Hid}"))
.Author(new Embed.EmbedAuthor(name, IconUrl: webhook_avatar.TryGetCleanCdnUrl(), Url: $"https://dash.pluralkit.me/profile/m/{member.Hid}"))
// .WithColor(member.ColorPrivacy.CanAccess(ctx) ? color : DiscordUtils.Gray)
.Color(color)
.Footer(new Embed.EmbedFooter(