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:
parent
7fffb7f65a
commit
ccb89f50e9
@ -304,6 +304,8 @@ public partial class CommandTree
|
|||||||
await ctx.Execute<MemberEdit>(MemberDelete, m => m.Delete(ctx, target));
|
await ctx.Execute<MemberEdit>(MemberDelete, m => m.Delete(ctx, target));
|
||||||
else if (ctx.Match("avatar", "profile", "picture", "icon", "image", "pfp", "pic"))
|
else if (ctx.Match("avatar", "profile", "picture", "icon", "image", "pfp", "pic"))
|
||||||
await ctx.Execute<MemberAvatar>(MemberAvatar, m => m.Avatar(ctx, target));
|
await ctx.Execute<MemberAvatar>(MemberAvatar, m => m.Avatar(ctx, target));
|
||||||
|
else if (ctx.Match("proxyavatar", "proxypfp", "webhookavatar", "webhookpfp", "pa"))
|
||||||
|
await ctx.Execute<MemberAvatar>(MemberAvatar, m => m.WebhookAvatar(ctx, target));
|
||||||
else if (ctx.Match("banner", "splash", "cover"))
|
else if (ctx.Match("banner", "splash", "cover"))
|
||||||
await ctx.Execute<MemberEdit>(MemberBannerImage, m => m.BannerImage(ctx, target));
|
await ctx.Execute<MemberEdit>(MemberBannerImage, m => m.BannerImage(ctx, target));
|
||||||
else if (ctx.Match("group", "groups"))
|
else if (ctx.Match("group", "groups"))
|
||||||
|
@ -15,10 +15,10 @@ public class MemberAvatar
|
|||||||
_client = client;
|
_client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AvatarClear(AvatarLocation location, Context ctx, PKMember target, MemberGuildSettings? mgs)
|
private async Task AvatarClear(MemberAvatarLocation location, Context ctx, PKMember target, MemberGuildSettings? mgs)
|
||||||
{
|
{
|
||||||
await UpdateAvatar(location, ctx, target, null);
|
await UpdateAvatar(location, ctx, target, null);
|
||||||
if (location == AvatarLocation.Server)
|
if (location == MemberAvatarLocation.Server)
|
||||||
{
|
{
|
||||||
if (target.AvatarUrl != null)
|
if (target.AvatarUrl != null)
|
||||||
await ctx.Reply(
|
await ctx.Reply(
|
||||||
@ -26,6 +26,14 @@ public class MemberAvatar
|
|||||||
else
|
else
|
||||||
await ctx.Reply($"{Emojis.Success} Member server avatar cleared. This member now has no avatar.");
|
await ctx.Reply($"{Emojis.Success} Member server avatar cleared. This member now has no avatar.");
|
||||||
}
|
}
|
||||||
|
else if (location == MemberAvatarLocation.MemberWebhook)
|
||||||
|
{
|
||||||
|
if (mgs?.AvatarUrl != null)
|
||||||
|
await ctx.Reply(
|
||||||
|
$"{Emojis.Success} Member proxy avatar cleared. Note that this member has a server-specific avatar set here, type `pk;member {target.Reference(ctx)} serveravatar clear` if you wish to clear that too.");
|
||||||
|
else
|
||||||
|
await ctx.Reply($"{Emojis.Success} Member proxy avatar cleared. This member will now use the main avatar for proxied messages.");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mgs?.AvatarUrl != null)
|
if (mgs?.AvatarUrl != null)
|
||||||
@ -36,18 +44,26 @@ public class MemberAvatar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AvatarShow(AvatarLocation location, Context ctx, PKMember target,
|
private async Task AvatarShow(MemberAvatarLocation location, Context ctx, PKMember target,
|
||||||
MemberGuildSettings? guildData)
|
MemberGuildSettings? guildData)
|
||||||
{
|
{
|
||||||
// todo: this privacy code is really confusing
|
// todo: this privacy code is really confusing
|
||||||
// for now, we skip privacy flag/config parsing for this, but it would be good to fix that at some point
|
// for now, we skip privacy flag/config parsing for this, but it would be good to fix that at some point
|
||||||
|
|
||||||
var currentValue = location == AvatarLocation.Member ? target.AvatarUrl : guildData?.AvatarUrl;
|
var currentValue = location switch
|
||||||
var canAccess = location != AvatarLocation.Member ||
|
{
|
||||||
|
MemberAvatarLocation.Server => guildData?.AvatarUrl,
|
||||||
|
MemberAvatarLocation.MemberWebhook => target.WebhookAvatarUrl,
|
||||||
|
MemberAvatarLocation.Member => target.AvatarUrl,
|
||||||
|
_ => throw new ArgumentOutOfRangeException(nameof(location))
|
||||||
|
};
|
||||||
|
|
||||||
|
var canAccess = location == MemberAvatarLocation.Server ||
|
||||||
target.AvatarPrivacy.CanAccess(ctx.DirectLookupContextFor(target.System));
|
target.AvatarPrivacy.CanAccess(ctx.DirectLookupContextFor(target.System));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(currentValue) || !canAccess)
|
if (string.IsNullOrEmpty(currentValue) || !canAccess)
|
||||||
{
|
{
|
||||||
if (location == AvatarLocation.Member)
|
if (location == MemberAvatarLocation.Member)
|
||||||
{
|
{
|
||||||
if (target.System == ctx.System?.Id)
|
if (target.System == ctx.System?.Id)
|
||||||
throw new PKSyntaxError(
|
throw new PKSyntaxError(
|
||||||
@ -55,19 +71,24 @@ public class MemberAvatar
|
|||||||
throw new PKError("This member does not have an avatar set.");
|
throw new PKError("This member does not have an avatar set.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location == AvatarLocation.Server)
|
if (location == MemberAvatarLocation.MemberWebhook)
|
||||||
|
throw new PKError(
|
||||||
|
$"This member does not have a proxy avatar set. Type `pk;member {target.Reference(ctx)} avatar` to see their global avatar.");
|
||||||
|
|
||||||
|
if (location == MemberAvatarLocation.Server)
|
||||||
throw new PKError(
|
throw new PKError(
|
||||||
$"This member does not have a server avatar set. Type `pk;member {target.Reference(ctx)} avatar` to see their global avatar.");
|
$"This member does not have a server avatar set. Type `pk;member {target.Reference(ctx)} avatar` to see their global avatar.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var field = location == AvatarLocation.Server ? $"server avatar (for {ctx.Guild.Name})" : "avatar";
|
var field = location.Name();
|
||||||
var cmd = location == AvatarLocation.Server ? "serveravatar" : "avatar";
|
if (location == MemberAvatarLocation.Server)
|
||||||
|
field += $" (for {ctx.Guild.Name})";
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
.Title($"{target.NameFor(ctx)}'s {field}")
|
.Title($"{target.NameFor(ctx)}'s {field}")
|
||||||
.Image(new Embed.EmbedImage(currentValue?.TryGetCleanCdnUrl()));
|
.Image(new Embed.EmbedImage(currentValue?.TryGetCleanCdnUrl()));
|
||||||
if (target.System == ctx.System?.Id)
|
if (target.System == ctx.System?.Id)
|
||||||
eb.Description($"To clear, use `pk;member {target.Reference(ctx)} {cmd} clear`.");
|
eb.Description($"To clear, use `pk;member {target.Reference(ctx)} {location.Command()} clear`.");
|
||||||
await ctx.Reply(embed: eb.Build());
|
await ctx.Reply(embed: eb.Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +96,7 @@ public class MemberAvatar
|
|||||||
{
|
{
|
||||||
ctx.CheckGuildContext();
|
ctx.CheckGuildContext();
|
||||||
var guildData = await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id);
|
var guildData = await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id);
|
||||||
await AvatarCommandTree(AvatarLocation.Server, ctx, target, guildData);
|
await AvatarCommandTree(MemberAvatarLocation.Server, ctx, target, guildData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Avatar(Context ctx, PKMember target)
|
public async Task Avatar(Context ctx, PKMember target)
|
||||||
@ -84,16 +105,23 @@ public class MemberAvatar
|
|||||||
? await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id)
|
? await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
await AvatarCommandTree(AvatarLocation.Member, ctx, target, guildData);
|
await AvatarCommandTree(MemberAvatarLocation.Member, ctx, target, guildData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AvatarCommandTree(AvatarLocation location, Context ctx, PKMember target,
|
public async Task WebhookAvatar(Context ctx, PKMember target)
|
||||||
|
{
|
||||||
|
var guildData = ctx.Guild != null
|
||||||
|
? await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
await AvatarCommandTree(MemberAvatarLocation.MemberWebhook, ctx, target, guildData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task AvatarCommandTree(MemberAvatarLocation location, Context ctx, PKMember target,
|
||||||
MemberGuildSettings? guildData)
|
MemberGuildSettings? guildData)
|
||||||
{
|
{
|
||||||
// First, see if we need to *clear*
|
// First, see if we need to *clear*
|
||||||
if (ctx.MatchClear() && await ctx.ConfirmClear(location == AvatarLocation.Server
|
if (ctx.MatchClear() && await ctx.ConfirmClear("this member's " + location.Name()))
|
||||||
? "this member's server avatar"
|
|
||||||
: "this member's avatar"))
|
|
||||||
{
|
{
|
||||||
ctx.CheckSystem().CheckOwnMember(target);
|
ctx.CheckSystem().CheckOwnMember(target);
|
||||||
await AvatarClear(location, ctx, target, guildData);
|
await AvatarClear(location, ctx, target, guildData);
|
||||||
@ -115,33 +143,30 @@ public class MemberAvatar
|
|||||||
await PrintResponse(location, ctx, target, avatarArg.Value, guildData);
|
await PrintResponse(location, ctx, target, avatarArg.Value, guildData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task PrintResponse(AvatarLocation location, Context ctx, PKMember target, ParsedImage avatar,
|
private Task PrintResponse(MemberAvatarLocation location, Context ctx, PKMember target, ParsedImage avatar,
|
||||||
MemberGuildSettings? targetGuildData)
|
MemberGuildSettings? targetGuildData)
|
||||||
{
|
{
|
||||||
var typeFrag = location switch
|
|
||||||
{
|
|
||||||
AvatarLocation.Server => "server avatar",
|
|
||||||
AvatarLocation.Member => "avatar",
|
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(location))
|
|
||||||
};
|
|
||||||
|
|
||||||
var serverFrag = location switch
|
var serverFrag = location switch
|
||||||
{
|
{
|
||||||
AvatarLocation.Server =>
|
MemberAvatarLocation.Server =>
|
||||||
$" This avatar will now be used when proxying in this server (**{ctx.Guild.Name}**).",
|
$" This avatar will now be used when proxying in this server (**{ctx.Guild.Name}**).",
|
||||||
AvatarLocation.Member when targetGuildData?.AvatarUrl != null =>
|
MemberAvatarLocation.Member when targetGuildData?.AvatarUrl != null =>
|
||||||
$"\n{Emojis.Note} Note that this member *also* has a server-specific avatar set in this server (**{ctx.Guild.Name}**), and thus changing the global avatar will have no effect here.",
|
$"\n{Emojis.Note} Note that this member *also* has a server-specific avatar set in this server (**{ctx.Guild.Name}**), and thus changing the global avatar will have no effect here.",
|
||||||
|
MemberAvatarLocation.MemberWebhook when targetGuildData?.AvatarUrl != null =>
|
||||||
|
$" This avatar will now be used for this member's proxied messages, instead of their main avatar.\n{Emojis.Note} Note that this member *also* has a server-specific avatar set in this server (**{ctx.Guild.Name}**), and thus changing the global avatar will have no effect here.",
|
||||||
|
MemberAvatarLocation.MemberWebhook =>
|
||||||
|
$" This avatar will now be used for this member's proxied messages, instead of their main avatar.",
|
||||||
_ => ""
|
_ => ""
|
||||||
};
|
};
|
||||||
|
|
||||||
var msg = avatar.Source switch
|
var msg = avatar.Source switch
|
||||||
{
|
{
|
||||||
AvatarSource.User =>
|
AvatarSource.User =>
|
||||||
$"{Emojis.Success} Member {typeFrag} changed to {avatar.SourceUser?.Username}'s avatar!{serverFrag}\n{Emojis.Warn} If {avatar.SourceUser?.Username} changes their avatar, the member's avatar will need to be re-set.",
|
$"{Emojis.Success} Member {location.Name()} changed to {avatar.SourceUser?.Username}'s avatar!{serverFrag}\n{Emojis.Warn} If {avatar.SourceUser?.Username} changes their avatar, the member's avatar will need to be re-set.",
|
||||||
AvatarSource.Url =>
|
AvatarSource.Url =>
|
||||||
$"{Emojis.Success} Member {typeFrag} changed to the image at the given URL.{serverFrag}",
|
$"{Emojis.Success} Member {location.Name()} changed to the image at the given URL.{serverFrag}",
|
||||||
AvatarSource.Attachment =>
|
AvatarSource.Attachment =>
|
||||||
$"{Emojis.Success} Member {typeFrag} changed to attached image.{serverFrag}\n{Emojis.Warn} If you delete the message containing the attachment, the avatar will stop working.",
|
$"{Emojis.Success} Member {location.Name()} changed to attached image.{serverFrag}\n{Emojis.Warn} If you delete the message containing the attachment, the avatar will stop working.",
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -152,18 +177,49 @@ public class MemberAvatar
|
|||||||
: ctx.Reply(msg);
|
: ctx.Reply(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task UpdateAvatar(AvatarLocation location, Context ctx, PKMember target, string? url)
|
private Task UpdateAvatar(MemberAvatarLocation location, Context ctx, PKMember target, string? url)
|
||||||
{
|
{
|
||||||
switch (location)
|
switch (location)
|
||||||
{
|
{
|
||||||
case AvatarLocation.Server:
|
case MemberAvatarLocation.Server:
|
||||||
return ctx.Repository.UpdateMemberGuild(target.Id, ctx.Guild.Id, new MemberGuildPatch { AvatarUrl = url });
|
return ctx.Repository.UpdateMemberGuild(target.Id, ctx.Guild.Id, new MemberGuildPatch { AvatarUrl = url });
|
||||||
case AvatarLocation.Member:
|
case MemberAvatarLocation.Member:
|
||||||
return ctx.Repository.UpdateMember(target.Id, new MemberPatch { AvatarUrl = url });
|
return ctx.Repository.UpdateMember(target.Id, new MemberPatch { AvatarUrl = url });
|
||||||
|
case MemberAvatarLocation.MemberWebhook:
|
||||||
|
return ctx.Repository.UpdateMember(target.Id, new MemberPatch { WebhookAvatarUrl = url });
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException($"Unknown avatar location {location}");
|
throw new ArgumentOutOfRangeException($"Unknown avatar location {location}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private enum AvatarLocation { Member, Server }
|
internal enum MemberAvatarLocation
|
||||||
|
{
|
||||||
|
Member,
|
||||||
|
MemberWebhook,
|
||||||
|
Server,
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static class MemberAvatarLocationExt
|
||||||
|
{
|
||||||
|
public static string Name(this MemberAvatarLocation location)
|
||||||
|
{
|
||||||
|
return location switch
|
||||||
|
{
|
||||||
|
MemberAvatarLocation.Server => "server avatar",
|
||||||
|
MemberAvatarLocation.MemberWebhook => "proxy avatar",
|
||||||
|
MemberAvatarLocation.Member => "avatar",
|
||||||
|
_ => throw new ArgumentOutOfRangeException(nameof(location))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Command(this MemberAvatarLocation location)
|
||||||
|
{
|
||||||
|
return location switch
|
||||||
|
{
|
||||||
|
MemberAvatarLocation.Server => "serveravatar",
|
||||||
|
MemberAvatarLocation.MemberWebhook => "proxyavatar",
|
||||||
|
MemberAvatarLocation.Member => "avatar",
|
||||||
|
_ => throw new ArgumentOutOfRangeException(nameof(location))
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
@ -135,7 +135,7 @@ public class EmbedService
|
|||||||
// sometimes Discord will just... not return the avatar hash with webhook messages
|
// sometimes Discord will just... not return the avatar hash with webhook messages
|
||||||
var avatar = proxiedMessage.Author.Avatar != null
|
var avatar = proxiedMessage.Author.Avatar != null
|
||||||
? proxiedMessage.Author.AvatarUrl()
|
? proxiedMessage.Author.AvatarUrl()
|
||||||
: member.AvatarFor(LookupContext.ByNonOwner);
|
: member.WebhookAvatarFor(LookupContext.ByNonOwner);
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.Author(new Embed.EmbedAuthor($"#{channelName}: {name}", IconUrl: avatar))
|
.Author(new Embed.EmbedAuthor($"#{channelName}: {name}", IconUrl: avatar))
|
||||||
.Thumbnail(new Embed.EmbedThumbnail(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 guildSettings = guild != null ? await _repo.GetMemberGuild(guild.Id, member.Id) : null;
|
||||||
var guildDisplayName = guildSettings?.DisplayName;
|
var guildDisplayName = guildSettings?.DisplayName;
|
||||||
|
var webhook_avatar = guildSettings?.AvatarUrl ?? member.WebhookAvatarFor(ctx) ?? member.AvatarFor(ctx);
|
||||||
var avatar = guildSettings?.AvatarUrl ?? member.AvatarFor(ctx);
|
var avatar = guildSettings?.AvatarUrl ?? member.AvatarFor(ctx);
|
||||||
|
|
||||||
var groups = await _repo.GetMemberGroups(member.Id)
|
var groups = await _repo.GetMemberGroups(member.Id)
|
||||||
@ -183,7 +184,7 @@ public class EmbedService
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
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)
|
// .WithColor(member.ColorPrivacy.CanAccess(ctx) ? color : DiscordUtils.Gray)
|
||||||
.Color(color)
|
.Color(color)
|
||||||
.Footer(new Embed.EmbedFooter(
|
.Footer(new Embed.EmbedFooter(
|
||||||
|
@ -23,9 +23,9 @@ public class ProxyMember
|
|||||||
public string Name { get; } = "";
|
public string Name { get; } = "";
|
||||||
|
|
||||||
public string? ServerAvatar { get; }
|
public string? ServerAvatar { get; }
|
||||||
|
public string? WebhookAvatar { get; }
|
||||||
public string? Avatar { get; }
|
public string? Avatar { get; }
|
||||||
|
|
||||||
|
|
||||||
public bool AllowAutoproxy { get; }
|
public bool AllowAutoproxy { get; }
|
||||||
public string? Color { get; }
|
public string? Color { get; }
|
||||||
|
|
||||||
@ -42,5 +42,5 @@ public class ProxyMember
|
|||||||
return memberName;
|
return memberName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? Avatar ?? ctx.SystemAvatar;
|
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? WebhookAvatar ?? Avatar ?? ctx.SystemAvatar;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
create function message_context(account_id bigint, guild_id bigint, channel_id bigint)
|
create function message_context(account_id bigint, guild_id bigint, channel_id bigint)
|
||||||
returns table (
|
returns table (
|
||||||
system_id int,
|
system_id int,
|
||||||
log_channel bigint,
|
log_channel bigint,
|
||||||
@ -67,6 +67,7 @@ create function proxy_members(account_id bigint, guild_id bigint)
|
|||||||
name text,
|
name text,
|
||||||
|
|
||||||
server_avatar text,
|
server_avatar text,
|
||||||
|
webhook_avatar text,
|
||||||
avatar text,
|
avatar text,
|
||||||
|
|
||||||
color char(6),
|
color char(6),
|
||||||
@ -87,6 +88,7 @@ as $$
|
|||||||
|
|
||||||
-- Avatar info
|
-- Avatar info
|
||||||
member_guild.avatar_url as server_avatar,
|
member_guild.avatar_url as server_avatar,
|
||||||
|
members.webhook_avatar_url as webhook_avatar,
|
||||||
members.avatar_url as avatar,
|
members.avatar_url as avatar,
|
||||||
|
|
||||||
members.color as color,
|
members.color as color,
|
||||||
|
6
PluralKit.Core/Database/Migrations/33.sql
Normal file
6
PluralKit.Core/Database/Migrations/33.sql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
-- database version 33
|
||||||
|
-- add webhook_avatar_url to system members
|
||||||
|
|
||||||
|
alter table members add column webhook_avatar_url text;
|
||||||
|
|
||||||
|
update info set schema_version = 33;
|
@ -9,7 +9,7 @@ namespace PluralKit.Core;
|
|||||||
internal class DatabaseMigrator
|
internal class DatabaseMigrator
|
||||||
{
|
{
|
||||||
private const string RootPath = "PluralKit.Core.Database"; // "resource path" root for SQL files
|
private const string RootPath = "PluralKit.Core.Database"; // "resource path" root for SQL files
|
||||||
private const int TargetSchemaVersion = 32;
|
private const int TargetSchemaVersion = 33;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public DatabaseMigrator(ILogger logger)
|
public DatabaseMigrator(ILogger logger)
|
||||||
|
@ -39,6 +39,7 @@ public class PKMember
|
|||||||
public Guid Uuid { get; private set; }
|
public Guid Uuid { get; private set; }
|
||||||
public SystemId System { get; private set; }
|
public SystemId System { get; private set; }
|
||||||
public string Color { get; private set; }
|
public string Color { get; private set; }
|
||||||
|
public string WebhookAvatarUrl { get; private set; }
|
||||||
public string AvatarUrl { get; private set; }
|
public string AvatarUrl { get; private set; }
|
||||||
public string BannerImage { get; private set; }
|
public string BannerImage { get; private set; }
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
@ -90,6 +91,9 @@ public static class PKMemberExt
|
|||||||
public static string AvatarFor(this PKMember member, LookupContext ctx) =>
|
public static string AvatarFor(this PKMember member, LookupContext ctx) =>
|
||||||
member.AvatarPrivacy.Get(ctx, member.AvatarUrl.TryGetCleanCdnUrl());
|
member.AvatarPrivacy.Get(ctx, member.AvatarUrl.TryGetCleanCdnUrl());
|
||||||
|
|
||||||
|
public static string WebhookAvatarFor(this PKMember member, LookupContext ctx) =>
|
||||||
|
member.AvatarPrivacy.Get(ctx, (member.WebhookAvatarUrl ?? member.AvatarUrl).TryGetCleanCdnUrl());
|
||||||
|
|
||||||
public static string DescriptionFor(this PKMember member, LookupContext ctx) =>
|
public static string DescriptionFor(this PKMember member, LookupContext ctx) =>
|
||||||
member.DescriptionPrivacy.Get(ctx, member.Description);
|
member.DescriptionPrivacy.Get(ctx, member.Description);
|
||||||
|
|
||||||
@ -128,6 +132,7 @@ public static class PKMemberExt
|
|||||||
o.Add("birthday", member.BirthdayFor(ctx)?.FormatExport());
|
o.Add("birthday", member.BirthdayFor(ctx)?.FormatExport());
|
||||||
o.Add("pronouns", member.PronounsFor(ctx));
|
o.Add("pronouns", member.PronounsFor(ctx));
|
||||||
o.Add("avatar_url", member.AvatarFor(ctx).TryGetCleanCdnUrl());
|
o.Add("avatar_url", member.AvatarFor(ctx).TryGetCleanCdnUrl());
|
||||||
|
o.Add("webhook_avatar_url", member.WebhookAvatarFor(ctx).TryGetCleanCdnUrl());
|
||||||
o.Add("banner", member.DescriptionPrivacy.Get(ctx, member.BannerImage).TryGetCleanCdnUrl());
|
o.Add("banner", member.DescriptionPrivacy.Get(ctx, member.BannerImage).TryGetCleanCdnUrl());
|
||||||
o.Add("description", member.DescriptionFor(ctx));
|
o.Add("description", member.DescriptionFor(ctx));
|
||||||
o.Add("created", member.CreatedFor(ctx)?.FormatExport());
|
o.Add("created", member.CreatedFor(ctx)?.FormatExport());
|
||||||
|
@ -12,6 +12,7 @@ public class MemberPatch: PatchObject
|
|||||||
public Partial<string> Name { get; set; }
|
public Partial<string> Name { get; set; }
|
||||||
public Partial<string> Hid { get; set; }
|
public Partial<string> Hid { get; set; }
|
||||||
public Partial<string?> DisplayName { get; set; }
|
public Partial<string?> DisplayName { get; set; }
|
||||||
|
public Partial<string?> WebhookAvatarUrl { get; set; }
|
||||||
public Partial<string?> AvatarUrl { get; set; }
|
public Partial<string?> AvatarUrl { get; set; }
|
||||||
public Partial<string?> BannerImage { get; set; }
|
public Partial<string?> BannerImage { get; set; }
|
||||||
public Partial<string?> Color { get; set; }
|
public Partial<string?> Color { get; set; }
|
||||||
@ -34,6 +35,7 @@ public class MemberPatch: PatchObject
|
|||||||
.With("name", Name)
|
.With("name", Name)
|
||||||
.With("hid", Hid)
|
.With("hid", Hid)
|
||||||
.With("display_name", DisplayName)
|
.With("display_name", DisplayName)
|
||||||
|
.With("webhook_avatar_url", WebhookAvatarUrl)
|
||||||
.With("avatar_url", AvatarUrl)
|
.With("avatar_url", AvatarUrl)
|
||||||
.With("banner_image", BannerImage)
|
.With("banner_image", BannerImage)
|
||||||
.With("color", Color)
|
.With("color", Color)
|
||||||
@ -62,6 +64,9 @@ public class MemberPatch: PatchObject
|
|||||||
if (AvatarUrl.Value != null)
|
if (AvatarUrl.Value != null)
|
||||||
AssertValid(AvatarUrl.Value, "avatar_url", Limits.MaxUriLength,
|
AssertValid(AvatarUrl.Value, "avatar_url", Limits.MaxUriLength,
|
||||||
s => MiscUtils.TryMatchUri(s, out var avatarUri));
|
s => MiscUtils.TryMatchUri(s, out var avatarUri));
|
||||||
|
if (WebhookAvatarUrl.Value != null)
|
||||||
|
AssertValid(WebhookAvatarUrl.Value, "webhook_avatar_url", Limits.MaxUriLength,
|
||||||
|
s => MiscUtils.TryMatchUri(s, out var webhookAvatarUri));
|
||||||
if (BannerImage.Value != null)
|
if (BannerImage.Value != null)
|
||||||
AssertValid(BannerImage.Value, "banner", Limits.MaxUriLength,
|
AssertValid(BannerImage.Value, "banner", Limits.MaxUriLength,
|
||||||
s => MiscUtils.TryMatchUri(s, out var bannerUri));
|
s => MiscUtils.TryMatchUri(s, out var bannerUri));
|
||||||
@ -93,6 +98,7 @@ public class MemberPatch: PatchObject
|
|||||||
if (o.ContainsKey("name")) patch.Name = o.Value<string>("name");
|
if (o.ContainsKey("name")) patch.Name = o.Value<string>("name");
|
||||||
if (o.ContainsKey("color")) patch.Color = o.Value<string>("color").NullIfEmpty()?.ToLower();
|
if (o.ContainsKey("color")) patch.Color = o.Value<string>("color").NullIfEmpty()?.ToLower();
|
||||||
if (o.ContainsKey("display_name")) patch.DisplayName = o.Value<string>("display_name").NullIfEmpty();
|
if (o.ContainsKey("display_name")) patch.DisplayName = o.Value<string>("display_name").NullIfEmpty();
|
||||||
|
if (o.ContainsKey("webhook_avatar_url")) patch.WebhookAvatarUrl = o.Value<string>("webhook_avatar_url").NullIfEmpty();
|
||||||
if (o.ContainsKey("avatar_url")) patch.AvatarUrl = o.Value<string>("avatar_url").NullIfEmpty();
|
if (o.ContainsKey("avatar_url")) patch.AvatarUrl = o.Value<string>("avatar_url").NullIfEmpty();
|
||||||
if (o.ContainsKey("banner")) patch.BannerImage = o.Value<string>("banner").NullIfEmpty();
|
if (o.ContainsKey("banner")) patch.BannerImage = o.Value<string>("banner").NullIfEmpty();
|
||||||
|
|
||||||
@ -177,6 +183,8 @@ public class MemberPatch: PatchObject
|
|||||||
o.Add("display_name", DisplayName.Value);
|
o.Add("display_name", DisplayName.Value);
|
||||||
if (AvatarUrl.IsPresent)
|
if (AvatarUrl.IsPresent)
|
||||||
o.Add("avatar_url", AvatarUrl.Value);
|
o.Add("avatar_url", AvatarUrl.Value);
|
||||||
|
if (WebhookAvatarUrl.IsPresent)
|
||||||
|
o.Add("webhook_avatar_url", WebhookAvatarUrl.Value);
|
||||||
if (BannerImage.IsPresent)
|
if (BannerImage.IsPresent)
|
||||||
o.Add("banner", BannerImage.Value);
|
o.Add("banner", BannerImage.Value);
|
||||||
if (Color.IsPresent)
|
if (Color.IsPresent)
|
||||||
|
@ -46,6 +46,7 @@ Every PluralKit entity has two IDs: a short (5-character) ID and a longer UUID.
|
|||||||
|birthday|?string|`YYYY-MM-DD` format, 0004 hides the year|
|
|birthday|?string|`YYYY-MM-DD` format, 0004 hides the year|
|
||||||
|pronouns|?string|100-character-limit|
|
|pronouns|?string|100-character-limit|
|
||||||
|avatar_url|?string|256-character limit, must be a publicly-accessible URL|
|
|avatar_url|?string|256-character limit, must be a publicly-accessible URL|
|
||||||
|
|webhook_avatar_url|?string|256-character limit, must be a publicly-accessible URL|
|
||||||
|banner|?string|256-character limit, must be a publicly-accessible URL|
|
|banner|?string|256-character limit, must be a publicly-accessible URL|
|
||||||
|description|?string|1000-character limit|
|
|description|?string|1000-character limit|
|
||||||
|created|?datetime||
|
|created|?datetime||
|
||||||
|
@ -65,6 +65,7 @@ Some arguments indicate the use of specific Discord features. These include:
|
|||||||
- `pk;member <member> servername <new server name>` - Changes the display name of a member, only in the current server.
|
- `pk;member <member> servername <new server name>` - Changes the display name of a member, only in the current server.
|
||||||
- `pk;member <member> description [description]` - Changes the description of a member.
|
- `pk;member <member> description [description]` - Changes the description of a member.
|
||||||
- `pk;member <member> avatar [avatar url|@mention|upload]` - Changes the avatar of a member.
|
- `pk;member <member> avatar [avatar url|@mention|upload]` - Changes the avatar of a member.
|
||||||
|
- `pk;member <member> proxyavatar [avatar url|@mention|upload]` - Changes the avatar used for proxied messages sent by a member.
|
||||||
- `pk;member <member> serveravatar [avatar url|@mention|upload]` - Changes the avatar of a member in a specific server.
|
- `pk;member <member> serveravatar [avatar url|@mention|upload]` - Changes the avatar of a member in a specific server.
|
||||||
- `pk;member <name> banner [image url|upload]` - Changes the banner image of a member.
|
- `pk;member <name> banner [image url|upload]` - Changes the banner image of a member.
|
||||||
- `pk;member <member> privacy` - Displays a members current privacy settings.
|
- `pk;member <member> privacy` - Displays a members current privacy settings.
|
||||||
|
@ -229,6 +229,13 @@ To preview the current avatar (if one is set), use the command with no arguments
|
|||||||
|
|
||||||
To clear your avatar, use the subcommand `avatar clear` (eg. `pk;member John avatar clear`).
|
To clear your avatar, use the subcommand `avatar clear` (eg. `pk;member John avatar clear`).
|
||||||
|
|
||||||
|
### Member proxy avatar
|
||||||
|
If you want your member to have a different avatar for proxies messages than the one displayed on the member card, you can set a proxy avatar. To do so, use the `pk;member proxyavatar` command, in the same way as the normal avatar command above:
|
||||||
|
|
||||||
|
pk;member John avatar
|
||||||
|
pk;member John proxyavatar http://placebeard.it/512.jpg
|
||||||
|
pk;member "Craig Johnson" proxyavatar (with an attached image)
|
||||||
|
|
||||||
### Member server avatar
|
### Member server avatar
|
||||||
You can also set an avatar for a specific server. This will "override" the normal avatar, and will be used when proxying messages and looking up member cards in that server. To do so, use the `pk;member serveravatar` command, in the same way as the normal avatar command above:
|
You can also set an avatar for a specific server. This will "override" the normal avatar, and will be used when proxying messages and looking up member cards in that server. To do so, use the `pk;member serveravatar` command, in the same way as the normal avatar command above:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user