mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
implement show-embed flags
This commit is contained in:
parent
02a99025dc
commit
c00ff2f371
8 changed files with 24 additions and 20 deletions
|
|
@ -8,12 +8,12 @@ public partial class CommandTree
|
|||
{
|
||||
return command switch
|
||||
{
|
||||
Commands.Help => ctx.Execute<Help>(Help, m => m.HelpRoot(ctx)),
|
||||
Commands.Help(_, var flags) => ctx.Execute<Help>(Help, m => m.HelpRoot(ctx, flags.show_embed)),
|
||||
Commands.HelpCommands => ctx.Reply(
|
||||
"For the list of commands, see the website: <https://pluralkit.me/commands>"),
|
||||
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<Member>(MemberInfo, m => m.ViewMember(ctx, param.target)),
|
||||
Commands.MemberShow(var param, var flags) => ctx.Execute<Member>(MemberInfo, m => m.ViewMember(ctx, param.target, flags.show_embed)),
|
||||
Commands.MemberNew(var param, _) => ctx.Execute<Member>(MemberNew, m => m.NewMember(ctx, param.name)),
|
||||
Commands.MemberSoulscream(var param, _) => ctx.Execute<Member>(MemberInfo, m => m.Soulscream(ctx, param.target)),
|
||||
Commands.MemberAvatarShow(var param, var flags) => ctx.Execute<MemberAvatar>(MemberAvatar, m => m.ShowAvatar(ctx, param.target, flags.GetReplyFormat())),
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class EmbedService
|
|||
return Task.WhenAll(ids.Select(Inner));
|
||||
}
|
||||
|
||||
public async Task<MessageComponent[]> CreateSystemMessageComponents(Context cctx, PKSystem system, LookupContext ctx)
|
||||
public async Task<MessageComponent[]> 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;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,11 @@ pub fn all() -> impl Iterator<Item = Command> {
|
|||
.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"]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue