mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat: compress commands that give multiple responses into one response
This commit is contained in:
parent
b344b8ca41
commit
4782b5f825
4 changed files with 40 additions and 44 deletions
|
|
@ -91,11 +91,12 @@ public class Groups
|
||||||
$"> {ctx.DefaultPrefix}group **{reference}** description **This is my new group, and here is the description!**"))
|
$"> {ctx.DefaultPrefix}group **{reference}** description **This is my new group, and here is the description!**"))
|
||||||
.Field(new Embed.Field("Set the group icon",
|
.Field(new Embed.Field("Set the group icon",
|
||||||
$"> {ctx.DefaultPrefix}group **{reference}** icon\n*(with an image attached)*"));
|
$"> {ctx.DefaultPrefix}group **{reference}** icon\n*(with an image attached)*"));
|
||||||
await ctx.Reply($"{Emojis.Success} Group created!", eb.Build());
|
var replyStr = $"{Emojis.Success} Group created!";
|
||||||
|
|
||||||
if (existingGroupCount >= Limits.WarnThreshold(groupLimit))
|
if (existingGroupCount >= Limits.WarnThreshold(groupLimit))
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Warn} You are approaching the per-system group limit ({existingGroupCount} / {groupLimit} groups). Once you reach this limit, you will be unable to create new groups until existing groups are deleted, or you can ask for your limit to be raised in the PluralKit support server: <https://discord.gg/PczBt78>";
|
||||||
$"{Emojis.Warn} You are approaching the per-system group limit ({existingGroupCount} / {groupLimit} groups). Once you reach this limit, you will be unable to create new groups until existing groups are deleted, or you can ask for your limit to be raised in the PluralKit support server: <https://discord.gg/PczBt78>");
|
|
||||||
|
await ctx.Reply(replyStr, eb.Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RenameGroup(Context ctx, PKGroup target)
|
public async Task RenameGroup(Context ctx, PKGroup target)
|
||||||
|
|
@ -188,9 +189,10 @@ public class Groups
|
||||||
var patch = new GroupPatch { DisplayName = Partial<string>.Null() };
|
var patch = new GroupPatch { DisplayName = Partial<string>.Null() };
|
||||||
await ctx.Repository.UpdateGroup(target.Id, patch);
|
await ctx.Repository.UpdateGroup(target.Id, patch);
|
||||||
|
|
||||||
await ctx.Reply($"{Emojis.Success} Group display name cleared.");
|
var replyStr = $"{Emojis.Success} Group display name cleared.";
|
||||||
if (target.NamePrivacy == PrivacyLevel.Private)
|
if (target.NamePrivacy == PrivacyLevel.Private)
|
||||||
await ctx.Reply($"{Emojis.Warn} Since this group no longer has a display name set, their name privacy **can no longer take effect**.");
|
replyStr += $"\n{Emojis.Warn} Since this group no longer has a display name set, their name privacy **can no longer take effect**.";
|
||||||
|
await ctx.Reply(replyStr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -603,12 +605,12 @@ public class Groups
|
||||||
_ => throw new InvalidOperationException($"Invalid subject/level tuple ({subject}, {level})")
|
_ => throw new InvalidOperationException($"Invalid subject/level tuple ({subject}, {level})")
|
||||||
};
|
};
|
||||||
|
|
||||||
await ctx.Reply(
|
var replyStr = $"{Emojis.Success} {target.Name}'s **{subjectName}** has been set to **{level.LevelName()}**. {explanation}";
|
||||||
$"{Emojis.Success} {target.Name}'s **{subjectName}** has been set to **{level.LevelName()}**. {explanation}");
|
|
||||||
|
|
||||||
if (subject == GroupPrivacySubject.Name && level == PrivacyLevel.Private && target.DisplayName == null)
|
if (subject == GroupPrivacySubject.Name && level == PrivacyLevel.Private && target.DisplayName == null)
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Warn} This group does not have a display name set, and name privacy **will not take effect**.";
|
||||||
$"{Emojis.Warn} This group does not have a display name set, and name privacy **will not take effect**.");
|
|
||||||
|
await ctx.Reply(replyStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.Match("all") || newValueFromCommand != null)
|
if (ctx.Match("all") || newValueFromCommand != null)
|
||||||
|
|
|
||||||
|
|
@ -100,28 +100,23 @@ public class Member
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send confirmation and space hint
|
// Send confirmation and space hint
|
||||||
await ctx.Reply(
|
var replyStr = $"{Emojis.Success} Member \"{memberName}\" (`{member.DisplayHid(ctx.Config)}`) registered! Check out the getting started page for how to get a member up and running: https://pluralkit.me/start#create-a-member";
|
||||||
$"{Emojis.Success} Member \"{memberName}\" (`{member.DisplayHid(ctx.Config)}`) registered! Check out the getting started page for how to get a member up and running: https://pluralkit.me/start#create-a-member");
|
|
||||||
// todo: move this to ModelRepository
|
// todo: move this to ModelRepository
|
||||||
if (await ctx.Database.Execute(conn => conn.QuerySingleAsync<bool>("select has_private_members(@System)",
|
if (await ctx.Database.Execute(conn => conn.QuerySingleAsync<bool>("select has_private_members(@System)",
|
||||||
new { System = ctx.System.Id })) && !ctx.Config.MemberDefaultPrivate) //if has private members
|
new { System = ctx.System.Id })) && !ctx.Config.MemberDefaultPrivate) //if has private members
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Warn} This member is currently **public**. To change this, use `{ctx.DefaultPrefix}member {member.DisplayHid(ctx.Config)} private`.";
|
||||||
$"{Emojis.Warn} This member is currently **public**. To change this, use `{ctx.DefaultPrefix}member {member.DisplayHid(ctx.Config)} private`.");
|
|
||||||
if (avatarArg != null)
|
if (avatarArg != null)
|
||||||
if (imageMatchError == null)
|
if (imageMatchError == null)
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Success} Member avatar set to attached image." + (img.Source == AvatarSource.Attachment ? $"\n{Emojis.Warn} If you delete the message containing the attachment, the avatar will stop working." : "");
|
||||||
$"{Emojis.Success} Member avatar set to attached image." + (img.Source == AvatarSource.Attachment ? $"\n{Emojis.Warn} If you delete the message containing the attachment, the avatar will stop working." : ""));
|
|
||||||
else
|
else
|
||||||
await ctx.Reply($"{Emojis.Error} Couldn't set avatar: {imageMatchError.Message}");
|
replyStr += $"\n{Emojis.Error} Couldn't set avatar: {imageMatchError.Message}";
|
||||||
if (memberName.Contains(" "))
|
if (memberName.Contains(" "))
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Note} Note that this member's name contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it, or just use the member's short ID (which is `{member.DisplayHid(ctx.Config)}`).";
|
||||||
$"{Emojis.Note} Note that this member's name contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it, or just use the member's short ID (which is `{member.DisplayHid(ctx.Config)}`).");
|
|
||||||
if (memberCount >= memberLimit)
|
if (memberCount >= memberLimit)
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Warn} You have reached the per-system member limit ({memberLimit}). If you need to add more members, you can either delete existing members, or ask for your limit to be raised in the PluralKit support server: <https://discord.gg/PczBt78>";
|
||||||
$"{Emojis.Warn} You have reached the per-system member limit ({memberLimit}). If you need to add more members, you can either delete existing members, or ask for your limit to be raised in the PluralKit support server: <https://discord.gg/PczBt78>");
|
|
||||||
else if (memberCount >= Limits.WarnThreshold(memberLimit))
|
else if (memberCount >= Limits.WarnThreshold(memberLimit))
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Warn} You are approaching the per-system member limit ({memberCount} / {memberLimit} members). Once you reach this limit, you will be unable to create new members until existing members are deleted, or you can ask for your limit to be raised in the PluralKit support server: <https://discord.gg/PczBt78>";
|
||||||
$"{Emojis.Warn} You are approaching the per-system member limit ({memberCount} / {memberLimit} members). Once you reach this limit, you will be unable to create new members until existing members are deleted, or you can ask for your limit to be raised in the PluralKit support server: <https://discord.gg/PczBt78>");
|
await ctx.Reply(replyStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ViewMember(Context ctx, PKMember target)
|
public async Task ViewMember(Context ctx, PKMember target)
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,11 @@ public class MemberEdit
|
||||||
await ctx.Reply(target.NameFor(lctx), embed: eb.Build());
|
await ctx.Reply(target.NameFor(lctx), embed: eb.Build());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
var replyStr = $"Name for member {target.DisplayHid(ctx.Config)} is **{target.NameFor(lctx)}**.";
|
var replyStrQ = $"Name for member {target.DisplayHid(ctx.Config)} is **{target.NameFor(lctx)}**.";
|
||||||
if (target.System == ctx.System?.Id)
|
if (target.System == ctx.System?.Id)
|
||||||
replyStr += $"\nTo rename {target.DisplayHid(ctx.Config)} type `{ctx.DefaultPrefix}member {target.NameFor(ctx)} rename <new name>`."
|
replyStrQ += $"\nTo rename {target.DisplayHid(ctx.Config)} type `{ctx.DefaultPrefix}member {target.NameFor(ctx)} rename <new name>`."
|
||||||
+ $" Using {target.NameFor(lctx).Length}/{Limits.MaxMemberNameLength} characters.";
|
+ $" Using {target.NameFor(lctx).Length}/{Limits.MaxMemberNameLength} characters.";
|
||||||
await ctx.Reply(replyStr);
|
await ctx.Reply(replyStrQ);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -70,21 +70,19 @@ public class MemberEdit
|
||||||
var patch = new MemberPatch { Name = Partial<string>.Present(newName) };
|
var patch = new MemberPatch { Name = Partial<string>.Present(newName) };
|
||||||
await ctx.Repository.UpdateMember(target.Id, patch);
|
await ctx.Repository.UpdateMember(target.Id, patch);
|
||||||
|
|
||||||
await ctx.Reply($"{Emojis.Success} Member renamed (using {newName.Length}/{Limits.MaxMemberNameLength} characters).");
|
var replyStr = $"{Emojis.Success} Member renamed (using {newName.Length}/{Limits.MaxMemberNameLength} characters).";
|
||||||
if (newName.Contains(" "))
|
if (newName.Contains(" "))
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Note} Note that this member's name now contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it, or just use the member's short ID (which is `{target.DisplayHid(ctx.Config)}`).";
|
||||||
$"{Emojis.Note} Note that this member's name now contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it, or just use the member's short ID (which is `{target.DisplayHid(ctx.Config)}`).");
|
|
||||||
if (target.DisplayName != null)
|
if (target.DisplayName != null)
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Note} Note that this member has a display name set ({target.DisplayName}), and will be proxied using that name instead.";
|
||||||
$"{Emojis.Note} Note that this member has a display name set ({target.DisplayName}), and will be proxied using that name instead.");
|
|
||||||
|
|
||||||
if (ctx.Guild != null)
|
if (ctx.Guild != null)
|
||||||
{
|
{
|
||||||
var memberGuildConfig = await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id);
|
var memberGuildConfig = await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id);
|
||||||
if (memberGuildConfig.DisplayName != null)
|
if (memberGuildConfig.DisplayName != null)
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Note} Note that this member has a server name set ({memberGuildConfig.DisplayName}) in this server ({ctx.Guild.Name}), and will be proxied using that name here.";
|
||||||
$"{Emojis.Note} Note that this member has a server name set ({memberGuildConfig.DisplayName}) in this server ({ctx.Guild.Name}), and will be proxied using that name here.");
|
|
||||||
}
|
}
|
||||||
|
await ctx.Reply(replyStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Description(Context ctx, PKMember target)
|
public async Task Description(Context ctx, PKMember target)
|
||||||
|
|
@ -886,19 +884,18 @@ public class MemberEdit
|
||||||
_ => throw new InvalidOperationException($"Invalid subject/level tuple ({subject}, {level})")
|
_ => throw new InvalidOperationException($"Invalid subject/level tuple ({subject}, {level})")
|
||||||
};
|
};
|
||||||
|
|
||||||
await ctx.Reply(
|
var replyStr = $"{Emojis.Success} {target.NameFor(ctx)}'s **{subjectName}** has been set to **{level.LevelName()}**. {explanation}";
|
||||||
$"{Emojis.Success} {target.NameFor(ctx)}'s **{subjectName}** has been set to **{level.LevelName()}**. {explanation}");
|
|
||||||
|
|
||||||
// Name privacy only works given a display name
|
// Name privacy only works given a display name
|
||||||
if (subject == MemberPrivacySubject.Name && level == PrivacyLevel.Private && target.DisplayName == null)
|
if (subject == MemberPrivacySubject.Name && level == PrivacyLevel.Private && target.DisplayName == null)
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Warn} This member does not have a display name set, and name privacy **will not take effect**.";
|
||||||
$"{Emojis.Warn} This member does not have a display name set, and name privacy **will not take effect**.");
|
|
||||||
|
|
||||||
// Avatar privacy doesn't apply when proxying if no server avatar is set
|
// Avatar privacy doesn't apply when proxying if no server avatar is set
|
||||||
if (subject == MemberPrivacySubject.Avatar && level == PrivacyLevel.Private &&
|
if (subject == MemberPrivacySubject.Avatar && level == PrivacyLevel.Private &&
|
||||||
guildSettings?.AvatarUrl == null)
|
guildSettings?.AvatarUrl == null)
|
||||||
await ctx.Reply(
|
replyStr += $"\n{Emojis.Warn} This member does not have a server avatar set, so *proxying* will **still show the member avatar**. If you want to hide your avatar when proxying here, set a server avatar: `{ctx.DefaultPrefix}member {target.Reference(ctx)} serveravatar`";
|
||||||
$"{Emojis.Warn} This member does not have a server avatar set, so *proxying* will **still show the member avatar**. If you want to hide your avatar when proxying here, set a server avatar: `{ctx.DefaultPrefix}member {target.Reference(ctx)} serveravatar`");
|
|
||||||
|
await ctx.Reply(replyStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.Match("all") || newValueFromCommand != null)
|
if (ctx.Match("all") || newValueFromCommand != null)
|
||||||
|
|
|
||||||
|
|
@ -386,22 +386,24 @@ public class SystemEdit
|
||||||
|
|
||||||
await ctx.Repository.UpdateSystemGuild(target.Id, ctx.Guild.Id, new SystemGuildPatch { Tag = newTag });
|
await ctx.Repository.UpdateSystemGuild(target.Id, ctx.Guild.Id, new SystemGuildPatch { Tag = newTag });
|
||||||
|
|
||||||
await ctx.Reply(
|
var replyStr = $"{Emojis.Success} System server tag changed (using {newTag.Length}/{Limits.MaxSystemTagLength} characters). Member names will now have the tag {newTag.AsCode()} when proxied in the current server '{ctx.Guild.Name}'.\n\nTo check or change where your tag appears in your name use the command `{ctx.DefaultPrefix}cfg name format`.";
|
||||||
$"{Emojis.Success} System server tag changed (using {newTag.Length}/{Limits.MaxSystemTagLength} characters). Member names will now have the tag {newTag.AsCode()} when proxied in the current server '{ctx.Guild.Name}'.\n\nTo check or change where your tag appears in your name use the command `{ctx.DefaultPrefix}cfg name format`.");
|
|
||||||
|
|
||||||
if (!settings.TagEnabled)
|
if (!settings.TagEnabled)
|
||||||
await ctx.Reply(setDisabledWarning);
|
replyStr += "\n" + setDisabledWarning;
|
||||||
|
|
||||||
|
await ctx.Reply(replyStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task Clear()
|
async Task Clear()
|
||||||
{
|
{
|
||||||
await ctx.Repository.UpdateSystemGuild(target.Id, ctx.Guild.Id, new SystemGuildPatch { Tag = null });
|
await ctx.Repository.UpdateSystemGuild(target.Id, ctx.Guild.Id, new SystemGuildPatch { Tag = null });
|
||||||
|
|
||||||
await ctx.Reply(
|
var replyStr = $"{Emojis.Success} System server tag cleared. Member names will now use the global system tag, if there is one set.\n\nTo check or change where your tag appears in your name use the command `{ctx.DefaultPrefix}cfg name format`.";
|
||||||
$"{Emojis.Success} System server tag cleared. Member names will now use the global system tag, if there is one set.\n\nTo check or change where your tag appears in your name use the command `{ctx.DefaultPrefix}cfg name format`.");
|
|
||||||
|
|
||||||
if (!settings.TagEnabled)
|
if (!settings.TagEnabled)
|
||||||
await ctx.Reply(setDisabledWarning);
|
replyStr += "\n" + setDisabledWarning;
|
||||||
|
|
||||||
|
await ctx.Reply(replyStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task EnableDisable(bool newValue)
|
async Task EnableDisable(bool newValue)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue