Merge pull request #311 from Spectralitree/rawdisplaynames

Add raw display name printing
This commit is contained in:
Astrid 2021-05-07 10:37:54 +02:00 committed by GitHub
commit d719303053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 20 deletions

View File

@ -104,15 +104,30 @@ namespace PluralKit.Bot
else if (!ctx.HasNext()) else if (!ctx.HasNext())
{ {
// No perms check, display name isn't covered by member privacy // No perms check, display name isn't covered by member privacy
if (ctx.MatchFlag("r", "raw"))
{
if (target.DisplayName == null)
{
if (ctx.System?.Id == target.System)
await ctx.Reply($"This group does not have a display name set. To set one, type `pk;group {target.Reference()} displayname <display name>`.");
else
await ctx.Reply("This group does not have a display name set.");
}
else
await ctx.Reply($"```\n{target.DisplayName}\n```");
}
else
{
var eb = new EmbedBuilder() var eb = new EmbedBuilder()
.Field(new("Name", target.Name)) .Field(new("Name", target.Name))
.Field(new("Display Name", target.DisplayName ?? "*(none)*")); .Field(new("Display Name", target.DisplayName ?? "*(none)*"));
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
eb.Description($"To change display name, type `pk;group {target.Reference()} displayname <display name>`.\nTo clear it, type `pk;group {target.Reference()} displayname -clear`."); eb.Description($"To change display name, type `pk;group {target.Reference()} displayname <display name>`.\nTo clear it, type `pk;group {target.Reference()} displayname -clear`.\nTo print the raw display name, type `pk;group {target.Reference()} displayname -raw`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
} }
}
else else
{ {
ctx.CheckOwnGroup(target); ctx.CheckOwnGroup(target);

View File

@ -115,8 +115,10 @@ namespace PluralKit.Bot
await ctx.Reply($"This member does not have pronouns set. To set some, type `pk;member {target.Reference()} pronouns <pronouns>`."); await ctx.Reply($"This member does not have pronouns set. To set some, type `pk;member {target.Reference()} pronouns <pronouns>`.");
else else
await ctx.Reply("This member does not have pronouns set."); await ctx.Reply("This member does not have pronouns set.");
else if (ctx.MatchFlag("r", "raw"))
await ctx.Reply($"```\n{target.Pronouns}\n```");
else else
await ctx.Reply($"**{target.NameFor(ctx)}**'s pronouns are **{target.Pronouns}**." await ctx.Reply($"**{target.NameFor(ctx)}**'s pronouns are **{target.Pronouns}**.\nTo print the pronouns with formatting, type `pk;member {target.Reference()} pronouns -raw`."
+ (ctx.System?.Id == target.System ? $" To clear them, type `pk;member {target.Reference()} pronouns -clear`." : "")); + (ctx.System?.Id == target.System ? $" To clear them, type `pk;member {target.Reference()} pronouns -clear`." : ""));
} }
else else
@ -284,11 +286,26 @@ namespace PluralKit.Bot
else if (!ctx.HasNext()) else if (!ctx.HasNext())
{ {
// No perms check, display name isn't covered by member privacy // No perms check, display name isn't covered by member privacy
if (ctx.MatchFlag("r", "raw"))
{
if (target.DisplayName == null)
{
if (ctx.System?.Id == target.System)
await ctx.Reply($"This member does not have a display name set. To set one, type `pk;member {target.Reference()} displayname <display name>`.");
else
await ctx.Reply("This member does not have a display name set.");
}
else
await ctx.Reply($"```\n{target.DisplayName}\n```");
}
else
{
var eb = await CreateMemberNameInfoEmbed(ctx, target); var eb = await CreateMemberNameInfoEmbed(ctx, target);
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
eb.Description($"To change display name, type `pk;member {target.Reference()} displayname <display name>`.\nTo clear it, type `pk;member {target.Reference()} displayname -clear`."); eb.Description($"To change display name, type `pk;member {target.Reference()} displayname <display name>`.\nTo clear it, type `pk;member {target.Reference()} displayname -clear`.\nTo print the raw display name, type `pk;member {target.Reference()} displayname -raw`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
} }
}
else else
{ {
ctx.CheckOwnMember(target); ctx.CheckOwnMember(target);
@ -320,12 +337,29 @@ namespace PluralKit.Bot
} }
else if (!ctx.HasNext()) else if (!ctx.HasNext())
{ {
// No perms check, server name isn't covered by member privacy // No perms check, display name isn't covered by member privacy
if (ctx.MatchFlag("r", "raw"))
{
MemberGuildSettings memberGuildConfig = await _db.Execute(c => _repo.GetMemberGuild(c, ctx.Guild.Id, target.Id));
if (memberGuildConfig.DisplayName == null)
{
if (ctx.System?.Id == target.System)
await ctx.Reply($"This member does not have a server name set. To set one, type `pk;member {target.Reference()} servername <server name>`.");
else
await ctx.Reply("This member does not have a server name set.");
}
else
await ctx.Reply($"```\n{memberGuildConfig.DisplayName}\n```");
}
else
{
var eb = await CreateMemberNameInfoEmbed(ctx, target); var eb = await CreateMemberNameInfoEmbed(ctx, target);
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
eb.Description($"To change server name, type `pk;member {target.Reference()} servername <server name>`.\nTo clear it, type `pk;member {target.Reference()} servername -clear`."); eb.Description($"To change server name, type `pk;member {target.Reference()} servername <server name>`.\nTo clear it, type `pk;member {target.Reference()} servername -clear`.\nTo print the raw server name, type `pk;member {target.Reference()} servername -raw`.");
await ctx.Reply(embed: eb.Build()); await ctx.Reply(embed: eb.Build());
} }
}
else else
{ {
ctx.CheckOwnMember(target); ctx.CheckOwnMember(target);