diff --git a/PluralKit.Bot/CommandMeta/CommandTree.cs b/PluralKit.Bot/CommandMeta/CommandTree.cs index eb8c4f60..1f546baa 100644 --- a/PluralKit.Bot/CommandMeta/CommandTree.cs +++ b/PluralKit.Bot/CommandMeta/CommandTree.cs @@ -8,12 +8,12 @@ public partial class CommandTree { return command switch { - Commands.Help => ctx.Execute(Help, m => m.HelpRoot(ctx)), + Commands.Help(_, var flags) => ctx.Execute(Help, m => m.HelpRoot(ctx, flags.show_embed)), Commands.HelpCommands => ctx.Reply( "For the list of commands, see the website: "), Commands.HelpProxy => ctx.Reply( "The proxy help page has been moved! See the website: https://pluralkit.me/guide#proxying"), - Commands.MemberShow(var param, _) => ctx.Execute(MemberInfo, m => m.ViewMember(ctx, param.target)), + Commands.MemberShow(var param, var flags) => ctx.Execute(MemberInfo, m => m.ViewMember(ctx, param.target, flags.show_embed)), Commands.MemberNew(var param, _) => ctx.Execute(MemberNew, m => m.NewMember(ctx, param.name)), Commands.MemberSoulscream(var param, _) => ctx.Execute(MemberInfo, m => m.Soulscream(ctx, param.target)), Commands.MemberAvatarShow(var param, var flags) => ctx.Execute(MemberAvatar, m => m.ShowAvatar(ctx, param.target, flags.GetReplyFormat())), diff --git a/PluralKit.Bot/Commands/Groups.cs b/PluralKit.Bot/Commands/Groups.cs index b18764d2..e350ee58 100644 --- a/PluralKit.Bot/Commands/Groups.cs +++ b/PluralKit.Bot/Commands/Groups.cs @@ -517,10 +517,10 @@ public class Groups return title.ToString(); } - public async Task ShowGroupCard(Context ctx, PKGroup target) + public async Task ShowGroupCard(Context ctx, PKGroup target, bool showEmbed = false) { var system = await GetGroupSystem(ctx, target); - if (ctx.MatchFlag("show-embed", "se")) + if (showEmbed) { await ctx.Reply(text: EmbedService.LEGACY_EMBED_WARNING, embed: await _embeds.CreateGroupEmbed(ctx, system, target)); return; diff --git a/PluralKit.Bot/Commands/Help.cs b/PluralKit.Bot/Commands/Help.cs index 333f4997..36aa73f7 100644 --- a/PluralKit.Bot/Commands/Help.cs +++ b/PluralKit.Bot/Commands/Help.cs @@ -7,9 +7,9 @@ namespace PluralKit.Bot; public class Help { - public Task HelpRoot(Context ctx) + public Task HelpRoot(Context ctx, bool showEmbed = false) { - if (ctx.MatchFlag("show-embed", "se")) + if (showEmbed) return HelpRootOld(ctx); return ctx.Reply(BuildComponents(ctx.Author.Id, Help.Description.Replace("{prefix}", ctx.DefaultPrefix), -1)); diff --git a/PluralKit.Bot/Commands/Member.cs b/PluralKit.Bot/Commands/Member.cs index 196ec25f..45010f34 100644 --- a/PluralKit.Bot/Commands/Member.cs +++ b/PluralKit.Bot/Commands/Member.cs @@ -120,10 +120,10 @@ public class Member await ctx.Reply(replyStr); } - public async Task ViewMember(Context ctx, PKMember target) + public async Task ViewMember(Context ctx, PKMember target, bool showEmbed = false) { var system = await ctx.Repository.GetSystem(target.System); - if (ctx.MatchFlag("show-embed", "se")) + if (showEmbed) { await ctx.Reply( text: EmbedService.LEGACY_EMBED_WARNING, diff --git a/PluralKit.Bot/Commands/Random.cs b/PluralKit.Bot/Commands/Random.cs index 4b0aa8a4..b16fff6e 100644 --- a/PluralKit.Bot/Commands/Random.cs +++ b/PluralKit.Bot/Commands/Random.cs @@ -15,7 +15,7 @@ public class Random // todo: get postgresql to return one random member/group instead of querying all members/groups - public async Task Member(Context ctx, PKSystem target) + public async Task Member(Context ctx, PKSystem target, bool showEmbed = false) { if (target == null) throw Errors.NoSystemError(ctx.DefaultPrefix); @@ -37,7 +37,7 @@ public class Random var randInt = randGen.Next(members.Count); - if (ctx.MatchFlag("show-embed", "se")) + if (showEmbed) { await ctx.Reply( text: EmbedService.LEGACY_EMBED_WARNING, @@ -49,7 +49,7 @@ public class Random components: await _embeds.CreateMemberMessageComponents(target, members[randInt], ctx.Guild, ctx.Config, ctx.LookupContextFor(target.Id), ctx.Zone)); } - public async Task Group(Context ctx, PKSystem target) + public async Task Group(Context ctx, PKSystem target, bool showEmbed = false) { if (target == null) throw Errors.NoSystemError(ctx.DefaultPrefix); @@ -70,7 +70,7 @@ public class Random var randInt = randGen.Next(groups.Count()); - if (ctx.MatchFlag("show-embed", "se")) + if (showEmbed) { await ctx.Reply( text: EmbedService.LEGACY_EMBED_WARNING, @@ -82,7 +82,7 @@ public class Random components: await _embeds.CreateGroupMessageComponents(ctx, target, groups.ToArray()[randInt])); } - public async Task GroupMember(Context ctx, PKGroup group) + public async Task GroupMember(Context ctx, PKGroup group, bool showEmbed = false) { ctx.CheckSystemPrivacy(group.System, group.ListPrivacy); @@ -112,7 +112,7 @@ public class Random var randInt = randGen.Next(ms.Count); - if (ctx.MatchFlag("show-embed", "se")) + if (showEmbed) { await ctx.Reply( text: EmbedService.LEGACY_EMBED_WARNING, diff --git a/PluralKit.Bot/Commands/System.cs b/PluralKit.Bot/Commands/System.cs index 1c50beac..f803abc8 100644 --- a/PluralKit.Bot/Commands/System.cs +++ b/PluralKit.Bot/Commands/System.cs @@ -14,16 +14,16 @@ public class System _embeds = embeds; } - public async Task Query(Context ctx, PKSystem system, bool all, bool @public, bool @private) + public async Task Query(Context ctx, PKSystem system, bool all, bool @public, bool @private, bool showEmbed = false) { if (system == null) throw Errors.NoSystemError(ctx.DefaultPrefix); - if (ctx.MatchFlag("show-embed", "se")) + if (showEmbed) { await ctx.Reply(text: EmbedService.LEGACY_EMBED_WARNING, embed: await _embeds.CreateSystemEmbed(ctx, system, ctx.LookupContextFor(system.Id), all)); return; } - await ctx.Reply(components: await _embeds.CreateSystemMessageComponents(ctx, system, ctx.LookupContextFor(system.Id))); + await ctx.Reply(components: await _embeds.CreateSystemMessageComponents(ctx, system, ctx.LookupContextFor(system.Id), all)); } public async Task New(Context ctx, string? systemName) diff --git a/PluralKit.Bot/Services/EmbedService.cs b/PluralKit.Bot/Services/EmbedService.cs index 1a5cfdf2..4cf5158f 100644 --- a/PluralKit.Bot/Services/EmbedService.cs +++ b/PluralKit.Bot/Services/EmbedService.cs @@ -43,7 +43,7 @@ public class EmbedService return Task.WhenAll(ids.Select(Inner)); } - public async Task CreateSystemMessageComponents(Context cctx, PKSystem system, LookupContext ctx) + public async Task CreateSystemMessageComponents(Context cctx, PKSystem system, LookupContext ctx, bool countctxByOwner) { // Fetch/render info for all accounts simultaneously var accounts = await _repo.GetSystemAccounts(system.Id); @@ -55,7 +55,7 @@ public class EmbedService }; var countctx = LookupContext.ByNonOwner; - if (cctx.MatchFlag("a", "all")) + if (countctxByOwner) { if (system.Id == cctx.System?.Id) countctx = LookupContext.ByOwner; diff --git a/crates/command_definitions/src/lib.rs b/crates/command_definitions/src/lib.rs index 28715d5f..500499de 100644 --- a/crates/command_definitions/src/lib.rs +++ b/crates/command_definitions/src/lib.rs @@ -27,7 +27,11 @@ pub fn all() -> impl Iterator { .chain(config::cmds()) .chain(fun::cmds()) .chain(switch::cmds()) - .map(|cmd| cmd.flag(("plaintext", ["pt"])).flag(("raw", ["r"]))) + .map(|cmd| { + cmd.flag(("plaintext", ["pt"])) + .flag(("raw", ["r"])) + .flag(("show-embed", ["se"])) + }) } pub const RESET: (&str, [&str; 2]) = ("reset", ["clear", "default"]);