refactor: tweak -raw usage (#341)

Co-authored-by: spiral <spiral@spiral.sh>
This commit is contained in:
Spectralitree 2021-08-27 19:20:14 -04:00 committed by spiral
parent 2ddef25177
commit 0553e42eca
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31
4 changed files with 242 additions and 182 deletions

View File

@ -71,6 +71,9 @@ namespace PluralKit.Bot
return matched; return matched;
} }
public static bool MatchRaw(this Context ctx) =>
ctx.Match("r", "raw") || ctx.MatchFlag("r", "raw");
public static (ulong? messageId, ulong? channelId) MatchMessage(this Context ctx, bool parseRawMessageId) public static (ulong? messageId, ulong? channelId) MatchMessage(this Context ctx, bool parseRawMessageId)
{ {
if (ctx.Message.Type == Message.MessageType.Reply && ctx.Message.MessageReference?.MessageId != null) if (ctx.Message.Type == Message.MessageType.Reply && ctx.Message.MessageReference?.MessageId != null)

View File

@ -97,46 +97,51 @@ namespace PluralKit.Bot
public async Task GroupDisplayName(Context ctx, PKGroup target) public async Task GroupDisplayName(Context ctx, PKGroup target)
{ {
if (await ctx.MatchClear("this group's display name")) var noDisplayNameSetMessage = "This group does not have a display name set.";
if (ctx.System?.Id == target.System)
noDisplayNameSetMessage += $" To set one, type `pk;group {target.Reference()} displayname <display name>`.";
// No perms check, display name isn't covered by member privacy
if (!ctx.HasNext())
{ {
if (target.DisplayName == null)
await ctx.Reply(noDisplayNameSetMessage);
else
{
var eb = new EmbedBuilder()
.Field(new("Name", target.Name))
.Field(new("Display Name", target.DisplayName));
if (ctx.System?.Id == target.System)
eb.Description($"To change display name, type `pk;group {target.Reference()} displayname <display name>`."
+ "To clear it, type `pk;group {target.Reference()} displayname -clear`."
+ "To print the raw display name, type `pk;group {target.Reference()} displayname -raw`.");
await ctx.Reply(embed: eb.Build());
}
return;
}
if (ctx.MatchRaw())
{
if (target.DisplayName == null)
await ctx.Reply(noDisplayNameSetMessage);
else
await ctx.Reply($"```\n{target.DisplayName}\n```");
return;
}
ctx.CheckOwnGroup(target); ctx.CheckOwnGroup(target);
if (await ctx.MatchClear("this group's display name"))
{
var patch = new GroupPatch { DisplayName = Partial<string>.Null() }; var patch = new GroupPatch { DisplayName = Partial<string>.Null() };
await _db.Execute(conn => _repo.UpdateGroup(conn, target.Id, patch)); await _db.Execute(conn => _repo.UpdateGroup(conn, target.Id, patch));
await ctx.Reply($"{Emojis.Success} Group display name cleared."); await ctx.Reply($"{Emojis.Success} Group display name cleared.");
} }
else if (!ctx.HasNext())
{
// 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 else
{ {
var eb = new EmbedBuilder()
.Field(new("Name", target.Name))
.Field(new("Display Name", target.DisplayName ?? "*(none)*"));
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`.\nTo print the raw display name, type `pk;group {target.Reference()} displayname -raw`.");
await ctx.Reply(embed: eb.Build());
}
}
else
{
ctx.CheckOwnGroup(target);
var newDisplayName = ctx.RemainderOrNull(); var newDisplayName = ctx.RemainderOrNull();
var patch = new GroupPatch { DisplayName = Partial<string>.Present(newDisplayName) }; var patch = new GroupPatch { DisplayName = Partial<string>.Present(newDisplayName) };
@ -147,27 +152,18 @@ namespace PluralKit.Bot
} }
public async Task GroupDescription(Context ctx, PKGroup target) public async Task GroupDescription(Context ctx, PKGroup target)
{
if (await ctx.MatchClear("this group's description"))
{
ctx.CheckOwnGroup(target);
var patch = new GroupPatch { Description = Partial<string>.Null() };
await _db.Execute(conn => _repo.UpdateGroup(conn, target.Id, patch));
await ctx.Reply($"{Emojis.Success} Group description cleared.");
}
else if (!ctx.HasNext())
{ {
if (!target.DescriptionPrivacy.CanAccess(ctx.LookupContextFor(target.System))) if (!target.DescriptionPrivacy.CanAccess(ctx.LookupContextFor(target.System)))
throw Errors.LookupNotAllowed; throw Errors.LookupNotAllowed;
if (target.Description == null) var noDescriptionSetMessage = "This group does not have a description set.";
if (ctx.System?.Id == target.System) if (ctx.System?.Id == target.System)
await ctx.Reply($"This group does not have a description set. To set one, type `pk;group {target.Reference()} description <description>`."); noDescriptionSetMessage += $" To set one, type `pk;group {target.Reference()} description <description>`.";
else
await ctx.Reply("This group does not have a description set."); if (!ctx.HasNext())
else if (ctx.MatchFlag("r", "raw")) {
await ctx.Reply($"```\n{target.Description}\n```"); if (target.Description == null)
await ctx.Reply(noDescriptionSetMessage);
else else
await ctx.Reply(embed: new EmbedBuilder() await ctx.Reply(embed: new EmbedBuilder()
.Title("Group description") .Title("Group description")
@ -175,11 +171,27 @@ namespace PluralKit.Bot
.Field(new("\u200B", $"To print the description with formatting, type `pk;group {target.Reference()} description -raw`." .Field(new("\u200B", $"To print the description with formatting, type `pk;group {target.Reference()} description -raw`."
+ (ctx.System?.Id == target.System ? $" To clear it, type `pk;group {target.Reference()} description -clear`." : ""))) + (ctx.System?.Id == target.System ? $" To clear it, type `pk;group {target.Reference()} description -clear`." : "")))
.Build()); .Build());
return;
}
if (ctx.MatchRaw())
{
if (target.Description == null)
await ctx.Reply(noDescriptionSetMessage);
else
await ctx.Reply($"```\n{target.Description}\n```");
return;
}
ctx.CheckOwnGroup(target);
if (await ctx.MatchClear("this group's description"))
{
var patch = new GroupPatch { Description = Partial<string>.Null() };
await _db.Execute(conn => _repo.UpdateGroup(conn, target.Id, patch));
await ctx.Reply($"{Emojis.Success} Group description cleared.");
} }
else else
{ {
ctx.CheckOwnGroup(target);
var description = ctx.RemainderOrNull().NormalizeLineEndSpacing(); var description = ctx.RemainderOrNull().NormalizeLineEndSpacing();
if (description.IsLongerThan(Limits.MaxDescriptionLength)) if (description.IsLongerThan(Limits.MaxDescriptionLength))
throw Errors.DescriptionTooLongError(description.Length); throw Errors.DescriptionTooLongError(description.Length);

View File

@ -59,25 +59,17 @@ namespace PluralKit.Bot
public async Task Description(Context ctx, PKMember target) public async Task Description(Context ctx, PKMember target)
{ {
if (await ctx.MatchClear("this member's description")) var noDescriptionSetMessage = "This member does not have a description set.";
{ if (ctx.System?.Id == target.System)
ctx.CheckOwnMember(target); noDescriptionSetMessage += $" To set one, type `pk;member {target.Reference()} description <description>`.";
var patch = new MemberPatch { Description = Partial<string>.Null() };
await _db.Execute(conn => _repo.UpdateMember(conn, target.Id, patch));
await ctx.Reply($"{Emojis.Success} Member description cleared.");
}
else if (!ctx.HasNext())
{
if (!target.DescriptionPrivacy.CanAccess(ctx.LookupContextFor(target.System))) if (!target.DescriptionPrivacy.CanAccess(ctx.LookupContextFor(target.System)))
throw Errors.LookupNotAllowed; throw Errors.LookupNotAllowed;
if (!ctx.HasNext())
{
if (target.Description == null) if (target.Description == null)
if (ctx.System?.Id == target.System) await ctx.Reply(noDescriptionSetMessage);
await ctx.Reply($"This member does not have a description set. To set one, type `pk;member {target.Reference()} description <description>`.");
else
await ctx.Reply("This member does not have a description set.");
else if (ctx.MatchFlag("r", "raw"))
await ctx.Reply($"```\n{target.Description}\n```");
else else
await ctx.Reply(embed: new EmbedBuilder() await ctx.Reply(embed: new EmbedBuilder()
.Title("Member description") .Title("Member description")
@ -85,11 +77,27 @@ namespace PluralKit.Bot
.Field(new("\u200B", $"To print the description with formatting, type `pk;member {target.Reference()} description -raw`." .Field(new("\u200B", $"To print the description with formatting, type `pk;member {target.Reference()} description -raw`."
+ (ctx.System?.Id == target.System ? $" To clear it, type `pk;member {target.Reference()} description -clear`." : ""))) + (ctx.System?.Id == target.System ? $" To clear it, type `pk;member {target.Reference()} description -clear`." : "")))
.Build()); .Build());
return;
}
else if (ctx.MatchRaw())
{
if (target.Description == null)
await ctx.Reply(noDescriptionSetMessage);
else
await ctx.Reply($"```\n{target.Description}\n```");
return;
}
ctx.CheckOwnMember(target);
if (await ctx.MatchClear("this member's description"))
{
var patch = new MemberPatch { Description = Partial<string>.Null() };
await _db.Execute(conn => _repo.UpdateMember(conn, target.Id, patch));
await ctx.Reply($"{Emojis.Success} Member description cleared.");
} }
else else
{ {
ctx.CheckOwnMember(target);
var description = ctx.RemainderOrNull().NormalizeLineEndSpacing(); var description = ctx.RemainderOrNull().NormalizeLineEndSpacing();
if (description.IsLongerThan(Limits.MaxDescriptionLength)) if (description.IsLongerThan(Limits.MaxDescriptionLength))
throw Errors.DescriptionTooLongError(description.Length); throw Errors.DescriptionTooLongError(description.Length);
@ -103,33 +111,41 @@ namespace PluralKit.Bot
public async Task Pronouns(Context ctx, PKMember target) public async Task Pronouns(Context ctx, PKMember target)
{ {
if (await ctx.MatchClear("this member's pronouns")) var noPronounsSetMessage = "This member does not have pronouns set.";
if (ctx.System?.Id == target.System)
noPronounsSetMessage += $"To set some, type `pk;member {target.Reference()} pronouns <pronouns>`.";
if (!target.PronounPrivacy.CanAccess(ctx.LookupContextFor(target.System)))
throw Errors.LookupNotAllowed;
if (!ctx.HasNext())
{ {
if (target.Pronouns == null)
await ctx.Reply(noPronounsSetMessage);
else
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`." : ""));
return;
}
else if (ctx.MatchRaw())
{
if (target.Pronouns == null)
await ctx.Reply(noPronounsSetMessage);
else
await ctx.Reply($"```\n{target.Pronouns}\n```");
return;
}
ctx.CheckOwnMember(target); ctx.CheckOwnMember(target);
if (await ctx.MatchClear("this member's pronouns"))
{
var patch = new MemberPatch { Pronouns = Partial<string>.Null() }; var patch = new MemberPatch { Pronouns = Partial<string>.Null() };
await _db.Execute(conn => _repo.UpdateMember(conn, target.Id, patch)); await _db.Execute(conn => _repo.UpdateMember(conn, target.Id, patch));
await ctx.Reply($"{Emojis.Success} Member pronouns cleared."); await ctx.Reply($"{Emojis.Success} Member pronouns cleared.");
} }
else if (!ctx.HasNext())
{
if (!target.PronounPrivacy.CanAccess(ctx.LookupContextFor(target.System)))
throw Errors.LookupNotAllowed;
if (target.Pronouns == null)
if (ctx.System?.Id == target.System)
await ctx.Reply($"This member does not have pronouns set. To set some, type `pk;member {target.Reference()} pronouns <pronouns>`.");
else
await ctx.Reply("This member does not have pronouns set.");
else if (ctx.MatchFlag("r", "raw"))
await ctx.Reply($"```\n{target.Pronouns}\n```");
else
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`." : ""));
}
else else
{ {
ctx.CheckOwnMember(target);
var pronouns = ctx.RemainderOrNull().NormalizeLineEndSpacing(); var pronouns = ctx.RemainderOrNull().NormalizeLineEndSpacing();
if (pronouns.IsLongerThan(Limits.MaxPronounsLength)) if (pronouns.IsLongerThan(Limits.MaxPronounsLength))
throw Errors.MemberPronounsTooLongError(pronouns.Length); throw Errors.MemberPronounsTooLongError(pronouns.Length);
@ -332,42 +348,42 @@ namespace PluralKit.Bot
await ctx.Reply(successStr); await ctx.Reply(successStr);
} }
if (await ctx.MatchClear("this member's display name")) var noDisplayNameSetMessage = "This member does not have a display name set.";
if (ctx.System?.Id == target.System)
noDisplayNameSetMessage += $" To set one, type `pk;member {target.Reference()} displayname <display name>`.";
// No perms check, display name isn't covered by member privacy
if (!ctx.HasNext())
{ {
var eb = await CreateMemberNameInfoEmbed(ctx, target);
if (ctx.System?.Id == target.System)
eb.Description($"To change display name, type `pk;member {target.Reference()} displayname <display name>`."
+ "To clear it, type `pk;member {target.Reference()} displayname -clear`."
+ "To print the raw display name, type `pk;member {target.Reference()} displayname -raw`.");
await ctx.Reply(embed: eb.Build());
return;
}
else if (ctx.MatchRaw())
{
if (target.DisplayName == null)
await ctx.Reply(noDisplayNameSetMessage);
else
await ctx.Reply($"```\n{target.DisplayName}\n```");
return;
}
ctx.CheckOwnMember(target); ctx.CheckOwnMember(target);
if (await ctx.MatchClear("this member's display name"))
{
var patch = new MemberPatch { DisplayName = Partial<string>.Null() }; var patch = new MemberPatch { DisplayName = Partial<string>.Null() };
await _db.Execute(conn => _repo.UpdateMember(conn, target.Id, patch)); await _db.Execute(conn => _repo.UpdateMember(conn, target.Id, patch));
await PrintSuccess($"{Emojis.Success} Member display name cleared. This member will now be proxied using their member name \"{target.NameFor(ctx)}\"."); await PrintSuccess($"{Emojis.Success} Member display name cleared. This member will now be proxied using their member name \"{target.NameFor(ctx)}\".");
} }
else if (!ctx.HasNext())
{
// 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 else
{ {
var eb = await CreateMemberNameInfoEmbed(ctx, target);
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`.\nTo print the raw display name, type `pk;member {target.Reference()} displayname -raw`.");
await ctx.Reply(embed: eb.Build());
}
}
else
{
ctx.CheckOwnMember(target);
var newDisplayName = ctx.RemainderOrNull(); var newDisplayName = ctx.RemainderOrNull();
var patch = new MemberPatch { DisplayName = Partial<string>.Present(newDisplayName) }; var patch = new MemberPatch { DisplayName = Partial<string>.Present(newDisplayName) };
@ -381,10 +397,35 @@ namespace PluralKit.Bot
{ {
ctx.CheckGuildContext(); ctx.CheckGuildContext();
if (await ctx.MatchClear("this member's server name")) var noServerNameSetMessage = "This member does not have a server name set.";
if (ctx.System?.Id == target.System)
noServerNameSetMessage += $" To set one, type `pk;member {target.Reference()} servername <server name>`.";
// No perms check, display name isn't covered by member privacy
if (!ctx.HasNext())
{ {
var eb = await CreateMemberNameInfoEmbed(ctx, target);
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`.\nTo print the raw server name, type `pk;member {target.Reference()} servername -raw`.");
await ctx.Reply(embed: eb.Build());
return;
}
else if (ctx.MatchRaw())
{
MemberGuildSettings memberGuildConfig = await _db.Execute(c => _repo.GetMemberGuild(c, ctx.Guild.Id, target.Id));
if (memberGuildConfig.DisplayName == null)
await ctx.Reply(noServerNameSetMessage);
else
await ctx.Reply($"```\n{memberGuildConfig.DisplayName}\n```");
return;
}
ctx.CheckOwnMember(target); ctx.CheckOwnMember(target);
if (await ctx.MatchClear("this member's server name"))
{
var patch = new MemberGuildPatch { DisplayName = null }; var patch = new MemberGuildPatch { DisplayName = null };
await _db.Execute(conn => _repo.UpsertMemberGuild(conn, target.Id, ctx.Guild.Id, patch)); await _db.Execute(conn => _repo.UpsertMemberGuild(conn, target.Id, ctx.Guild.Id, patch));
@ -393,35 +434,8 @@ namespace PluralKit.Bot
else else
await ctx.Reply($"{Emojis.Success} Member server name cleared. This member will now be proxied using their member name \"{target.NameFor(ctx)}\" in this server ({ctx.Guild.Name})."); await ctx.Reply($"{Emojis.Success} Member server name cleared. This member will now be proxied using their member name \"{target.NameFor(ctx)}\" in this server ({ctx.Guild.Name}).");
} }
else if (!ctx.HasNext())
{
// 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 else
{ {
var eb = await CreateMemberNameInfoEmbed(ctx, target);
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`.\nTo print the raw server name, type `pk;member {target.Reference()} servername -raw`.");
await ctx.Reply(embed: eb.Build());
}
}
else
{
ctx.CheckOwnMember(target);
var newServerName = ctx.RemainderOrNull(); var newServerName = ctx.RemainderOrNull();
var patch = new MemberGuildPatch { DisplayName = newServerName }; var patch = new MemberGuildPatch { DisplayName = newServerName };

View File

@ -29,28 +29,39 @@ namespace PluralKit.Bot
public async Task Name(Context ctx) public async Task Name(Context ctx)
{ {
var noNameSetMessage = "Your system does not have a name set. Type `pk;system name <name>` to set one.";
ctx.CheckSystem(); ctx.CheckSystem();
if (!ctx.HasNext())
{
if (ctx.System.Name != null)
await ctx.Reply($"Your system's name is currently **{ctx.System.Name}**. Type `pk;system name -clear` to clear it.");
else
await ctx.Reply(noNameSetMessage);
return;
}
if (ctx.MatchRaw())
{
if (ctx.System.Name != null)
await ctx.Reply($"```\n{ctx.System.Name}\n```");
else
await ctx.Reply(noNameSetMessage);
return;
}
if (await ctx.MatchClear("your system's name")) if (await ctx.MatchClear("your system's name"))
{ {
var clearPatch = new SystemPatch { Name = null }; var clearPatch = new SystemPatch { Name = null };
await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id, clearPatch)); await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id, clearPatch));
await ctx.Reply($"{Emojis.Success} System name cleared."); await ctx.Reply($"{Emojis.Success} System name cleared.");
return;
} }
var newSystemName = ctx.RemainderOrNull();
if (newSystemName == null)
{
if (ctx.System.Name != null)
await ctx.Reply($"Your system's name is currently **{ctx.System.Name}**. Type `pk;system name -clear` to clear it.");
else else
await ctx.Reply("Your system currently does not have a name. Type `pk;system name <name>` to set one."); {
return; var newSystemName = ctx.RemainderOrNull();
}
if (newSystemName != null && newSystemName.Length > Limits.MaxSystemNameLength) if (newSystemName.Length > Limits.MaxSystemNameLength)
throw Errors.SystemNameTooLongError(newSystemName.Length); throw Errors.SystemNameTooLongError(newSystemName.Length);
var patch = new SystemPatch { Name = newSystemName }; var patch = new SystemPatch { Name = newSystemName };
@ -58,11 +69,35 @@ namespace PluralKit.Bot
await ctx.Reply($"{Emojis.Success} System name changed."); await ctx.Reply($"{Emojis.Success} System name changed.");
} }
}
public async Task Description(Context ctx) public async Task Description(Context ctx)
{ {
var noDescriptionSetMessage = "Your system does not have a description set. To set one, type `pk;s description <description>`.";
ctx.CheckSystem(); ctx.CheckSystem();
if (!ctx.HasNext())
{
if (ctx.System.Description == null)
await ctx.Reply(noDescriptionSetMessage);
else
await ctx.Reply(embed: new EmbedBuilder()
.Title("System description")
.Description(ctx.System.Description)
.Footer(new("To print the description with formatting, type `pk;s description -raw`. To clear it, type `pk;s description -clear`. To change it, type `pk;s description <new description>`."))
.Build());
return;
}
if (ctx.MatchRaw())
{
if (ctx.System.Description == null)
await ctx.Reply(noDescriptionSetMessage);
else
await ctx.Reply($"```\n{ctx.System.Description}\n```");
return;
}
if (await ctx.MatchClear("your system's description")) if (await ctx.MatchClear("your system's description"))
{ {
var patch = new SystemPatch { Description = null }; var patch = new SystemPatch { Description = null };
@ -71,23 +106,9 @@ namespace PluralKit.Bot
await ctx.Reply($"{Emojis.Success} System description cleared."); await ctx.Reply($"{Emojis.Success} System description cleared.");
return; return;
} }
else
{
var newDescription = ctx.RemainderOrNull()?.NormalizeLineEndSpacing(); var newDescription = ctx.RemainderOrNull()?.NormalizeLineEndSpacing();
if (newDescription == null)
{
if (ctx.System.Description == null)
await ctx.Reply("Your system does not have a description set. To set one, type `pk;s description <description>`.");
else if (ctx.MatchFlag("r", "raw"))
await ctx.Reply($"```\n{ctx.System.Description}\n```");
else
await ctx.Reply(embed: new EmbedBuilder()
.Title("System description")
.Description(ctx.System.Description)
.Footer(new("To print the description with formatting, type `pk;s description -raw`. To clear it, type `pk;s description -clear`. To change it, type `pk;s description <new description>`."))
.Build());
}
else
{
if (newDescription.Length > Limits.MaxDescriptionLength) throw Errors.DescriptionTooLongError(newDescription.Length); if (newDescription.Length > Limits.MaxDescriptionLength) throw Errors.DescriptionTooLongError(newDescription.Length);
var patch = new SystemPatch { Description = newDescription }; var patch = new SystemPatch { Description = newDescription };
@ -141,8 +162,25 @@ namespace PluralKit.Bot
public async Task Tag(Context ctx) public async Task Tag(Context ctx)
{ {
var noTagSetMessage = "You currently have no system tag. To set one, type `pk;s tag <tag>`.";
ctx.CheckSystem(); ctx.CheckSystem();
if (!ctx.HasNext(skipFlags: false))
{
if (ctx.System.Tag == null)
await ctx.Reply(noTagSetMessage);
else
await ctx.Reply($"Your current system tag is {ctx.System.Tag.AsCode()}. To change it, type `pk;s tag <tag>`. To clear it, type `pk;s tag -clear`.");
}
if (ctx.MatchRaw())
{
if (ctx.System.Tag == null)
await ctx.Reply(noTagSetMessage);
else
await ctx.Reply($"```\n{ctx.System.Tag}\n```");
}
if (await ctx.MatchClear("your system's tag")) if (await ctx.MatchClear("your system's tag"))
{ {
var patch = new SystemPatch { Tag = null }; var patch = new SystemPatch { Tag = null };
@ -150,13 +188,6 @@ namespace PluralKit.Bot
await ctx.Reply($"{Emojis.Success} System tag cleared."); await ctx.Reply($"{Emojis.Success} System tag cleared.");
} }
else if (!ctx.HasNext(skipFlags: false))
{
if (ctx.System.Tag == null)
await ctx.Reply($"You currently have no system tag. To set one, type `pk;s tag <tag>`.");
else
await ctx.Reply($"Your current system tag is {ctx.System.Tag.AsCode()}. To change it, type `pk;s tag <tag>`. To clear it, type `pk;s tag -clear`.");
}
else else
{ {
var newTag = ctx.RemainderOrNull(skipFlags: false); var newTag = ctx.RemainderOrNull(skipFlags: false);