feat: show display options in short member list
This commit is contained in:
parent
c27cbeed01
commit
2807906d79
@ -36,7 +36,7 @@ namespace PluralKit.Bot
|
|||||||
if (ctx.MatchFlag("by-display-name", "bdn")) p.SortProperty = SortProperty.DisplayName;
|
if (ctx.MatchFlag("by-display-name", "bdn")) p.SortProperty = SortProperty.DisplayName;
|
||||||
if (ctx.MatchFlag("by-id", "bid")) p.SortProperty = SortProperty.Hid;
|
if (ctx.MatchFlag("by-id", "bid")) p.SortProperty = SortProperty.Hid;
|
||||||
if (ctx.MatchFlag("by-message-count", "bmc")) p.SortProperty = SortProperty.MessageCount;
|
if (ctx.MatchFlag("by-message-count", "bmc")) p.SortProperty = SortProperty.MessageCount;
|
||||||
if (ctx.MatchFlag("by-created", "bc")) p.SortProperty = SortProperty.CreationDate;
|
if (ctx.MatchFlag("by-created", "bc", "bcd")) p.SortProperty = SortProperty.CreationDate;
|
||||||
if (ctx.MatchFlag("by-last-fronted", "by-last-front", "by-last-switch", "blf", "bls")) p.SortProperty = SortProperty.LastSwitch;
|
if (ctx.MatchFlag("by-last-fronted", "by-last-front", "by-last-switch", "blf", "bls")) p.SortProperty = SortProperty.LastSwitch;
|
||||||
if (ctx.MatchFlag("by-last-message", "blm", "blp")) p.SortProperty = SortProperty.LastMessage;
|
if (ctx.MatchFlag("by-last-message", "blm", "blp")) p.SortProperty = SortProperty.LastMessage;
|
||||||
if (ctx.MatchFlag("by-birthday", "by-birthdate", "bbd")) p.SortProperty = SortProperty.Birthdate;
|
if (ctx.MatchFlag("by-birthday", "by-birthdate", "bbd")) p.SortProperty = SortProperty.Birthdate;
|
||||||
@ -67,6 +67,8 @@ namespace PluralKit.Bot
|
|||||||
p.IncludeCreated = true;
|
p.IncludeCreated = true;
|
||||||
if (ctx.MatchFlag("with-avatar", "with-image", "wa", "wi", "ia", "ii", "img"))
|
if (ctx.MatchFlag("with-avatar", "with-image", "wa", "wi", "ia", "ii", "img"))
|
||||||
p.IncludeAvatar = true;
|
p.IncludeAvatar = true;
|
||||||
|
if (ctx.MatchFlag("with-pronouns", "wp"))
|
||||||
|
p.IncludePronouns = true;
|
||||||
|
|
||||||
// Always show the sort property, too
|
// Always show the sort property, too
|
||||||
if (p.SortProperty == SortProperty.LastSwitch) p.IncludeLastSwitch = true;
|
if (p.SortProperty == SortProperty.LastSwitch) p.IncludeLastSwitch = true;
|
||||||
@ -110,15 +112,57 @@ namespace PluralKit.Bot
|
|||||||
// so run it through a helper that "makes it work" :)
|
// so run it through a helper that "makes it work" :)
|
||||||
eb.WithSimpleLineContent(page.Select(m =>
|
eb.WithSimpleLineContent(page.Select(m =>
|
||||||
{
|
{
|
||||||
if (m.HasProxyTags)
|
var ret = $"[`{m.Hid}`] **{m.NameFor(ctx)}** ";
|
||||||
|
|
||||||
|
switch (opts.SortProperty) {
|
||||||
|
case SortProperty.Birthdate: {
|
||||||
|
var birthday = m.BirthdayFor(lookupCtx);
|
||||||
|
if (birthday != null)
|
||||||
|
ret += $"(birthday: {m.BirthdayString})";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SortProperty.MessageCount: {
|
||||||
|
if (m.MessageCountFor(lookupCtx) is {} count)
|
||||||
|
ret += $"({count} messages)";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SortProperty.LastSwitch: {
|
||||||
|
if (m.MetadataPrivacy.TryGet(lookupCtx, m.LastSwitchTime, out var lastSw))
|
||||||
|
ret += $"(last switched in: <t:{lastSw.Value.ToUnixTimeSeconds()}>)";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SortProperty.LastMessage: {
|
||||||
|
if (m.MetadataPrivacy.TryGet(lookupCtx, m.LastMessage, out var lastMsg))
|
||||||
|
ret += $"(last message: <t:{DiscordUtils.SnowflakeToInstant(lastMsg.Value).ToUnixTimeSeconds()}>)";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SortProperty.CreationDate: {
|
||||||
|
if (m.MetadataPrivacy.TryGet(lookupCtx, m.Created, out var created))
|
||||||
|
ret += $"(created at <t:{created.ToUnixTimeSeconds()}>)";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
if (opts.IncludeMessageCount && m.MessageCountFor(lookupCtx) is {} count)
|
||||||
|
ret += $"({count} messages)";
|
||||||
|
else if (opts.IncludeLastSwitch && m.MetadataPrivacy.TryGet(lookupCtx, m.LastSwitchTime, out var lastSw))
|
||||||
|
ret += $"(last switched in: <t:{lastSw.Value.ToUnixTimeSeconds()}>)";
|
||||||
|
else if (opts.IncludeLastMessage && m.MetadataPrivacy.TryGet(lookupCtx, m.LastMessage, out var lastMsg))
|
||||||
|
ret += $"(last message: <t:{DiscordUtils.SnowflakeToInstant(lastMsg.Value).ToUnixTimeSeconds()}>)";
|
||||||
|
else if (opts.IncludeCreated && m.MetadataPrivacy.TryGet(lookupCtx, m.Created, out var created))
|
||||||
|
ret += $"(created at <t:{created.ToUnixTimeSeconds()}>)";
|
||||||
|
else if (opts.IncludePronouns && m.PronounsFor(lookupCtx) is {} pronouns)
|
||||||
|
ret += $"({pronouns})";
|
||||||
|
else if (m.HasProxyTags)
|
||||||
{
|
{
|
||||||
var proxyTagsString = m.ProxyTagsString();
|
var proxyTagsString = m.ProxyTagsString();
|
||||||
if (proxyTagsString.Length > 100) // arbitrary threshold for now, tweak?
|
if (proxyTagsString.Length > 100) // arbitrary threshold for now, tweak?
|
||||||
proxyTagsString = "tags too long, see member card";
|
proxyTagsString = "tags too long, see member card";
|
||||||
return $"[`{m.Hid}`] **{m.NameFor(ctx)}** *(*{proxyTagsString}*)*";
|
ret += $"*(*{proxyTagsString}*)*";
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
return $"[`{m.Hid}`] **{m.NameFor(ctx)}**";
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ namespace PluralKit.Bot
|
|||||||
public bool IncludeLastMessage { get; set; }
|
public bool IncludeLastMessage { get; set; }
|
||||||
public bool IncludeCreated { get; set; }
|
public bool IncludeCreated { get; set; }
|
||||||
public bool IncludeAvatar { get; set; }
|
public bool IncludeAvatar { get; set; }
|
||||||
|
public bool IncludePronouns { get; set; }
|
||||||
|
|
||||||
public string CreateFilterString()
|
public string CreateFilterString()
|
||||||
{
|
{
|
||||||
|
@ -64,6 +64,7 @@ You cannot look up private members of another system.
|
|||||||
|-with-message-count|-wmc|Show each member's message count|
|
|-with-message-count|-wmc|Show each member's message count|
|
||||||
|-with-created|-wc|Show each member's creation date|
|
|-with-created|-wc|Show each member's creation date|
|
||||||
|-with-avatar|-wa, -wi, -ia, -ii, -img|Show each member's avatar URL|
|
|-with-avatar|-wa, -wi, -ia, -ii, -img|Show each member's avatar URL|
|
||||||
|
|-with-pronouns|-wp|Show each member's pronouns in the short list (shown by default in full list)|
|
||||||
|
|
||||||
::: warning
|
::: warning
|
||||||
These flags only work with the full member list (`pk;system list full`).
|
These flags only work with the full member list (`pk;system list full`).
|
||||||
|
Loading…
Reference in New Issue
Block a user