mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
make use of the new optional parsing and remove the _self commands
This commit is contained in:
parent
00d3840fd1
commit
32d481c6b9
3 changed files with 136 additions and 174 deletions
|
|
@ -122,75 +122,72 @@ public partial class CommandTree
|
|||
Commands.FunRool => ctx.Execute<Fun>(null, m => m.Rool(ctx)),
|
||||
Commands.Amogus => ctx.Execute<Fun>(null, m => m.Sus(ctx)),
|
||||
Commands.FunError => ctx.Execute<Fun>(null, m => m.Error(ctx)),
|
||||
Commands.SystemInfo(var param, var flags) => ctx.Execute<System>(SystemInfo, m => m.Query(ctx, param.target, flags.all, flags.@public, flags.@private)),
|
||||
Commands.SystemInfoSelf(_, var flags) => ctx.Execute<System>(SystemInfo, m => m.Query(ctx, ctx.System, flags.all, flags.@public, flags.@private)),
|
||||
Commands.SystemNew(var param, _) => ctx.Execute<System>(SystemNew, m => m.New(ctx, null)),
|
||||
Commands.SystemNewName(var param, _) => ctx.Execute<System>(SystemNew, m => m.New(ctx, param.name)),
|
||||
Commands.SystemShowNameSelf(_, var flags) => ctx.Execute<SystemEdit>(SystemRename, m => m.ShowName(ctx, ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemShowName(var param, var flags) => ctx.Execute<SystemEdit>(SystemRename, m => m.ShowName(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemInfo(var param, var flags) => ctx.Execute<System>(SystemInfo, m => m.Query(ctx, param.target ?? ctx.System, flags.all, flags.@public, flags.@private)),
|
||||
Commands.SystemNew(var param, _) => ctx.Execute<System>(SystemNew, m => m.New(ctx, param.name)),
|
||||
Commands.SystemShowName(var param, var flags) => ctx.Execute<SystemEdit>(SystemRename, m => m.ShowName(ctx, param.target ?? ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemRename(var param, _) => ctx.Execute<SystemEdit>(SystemRename, m => m.Rename(ctx, ctx.System, param.name)),
|
||||
Commands.SystemClearName(var param, var flags) => ctx.Execute<SystemEdit>(SystemRename, m => m.ClearName(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemShowServerNameSelf(_, var flags) => ctx.Execute<SystemEdit>(SystemServerName, m => m.ShowServerName(ctx, ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemShowServerName(var param, var flags) => ctx.Execute<SystemEdit>(SystemServerName, m => m.ShowServerName(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemShowServerName(var param, var flags) => ctx.Execute<SystemEdit>(SystemServerName, m => m.ShowServerName(ctx, param.target ?? ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemClearServerName(var param, var flags) => ctx.Execute<SystemEdit>(SystemServerName, m => m.ClearServerName(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemRenameServerName(var param, _) => ctx.Execute<SystemEdit>(SystemServerName, m => m.RenameServerName(ctx, ctx.System, param.name)),
|
||||
Commands.SystemShowDescriptionSelf(_, var flags) => ctx.Execute<SystemEdit>(SystemDesc, m => m.ShowDescription(ctx, ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemShowDescription(var param, var flags) => ctx.Execute<SystemEdit>(SystemDesc, m => m.ShowDescription(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemShowDescription(var param, var flags) => ctx.Execute<SystemEdit>(SystemDesc, m => m.ShowDescription(ctx, param.target ?? ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemClearDescription(var param, var flags) => ctx.Execute<SystemEdit>(SystemDesc, m => m.ClearDescription(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemChangeDescription(var param, _) => ctx.Execute<SystemEdit>(SystemDesc, m => m.ChangeDescription(ctx, ctx.System, param.description)),
|
||||
Commands.SystemShowColorSelf(_, var flags) => ctx.Execute<SystemEdit>(SystemColor, m => m.ShowColor(ctx, ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemShowColor(var param, var flags) => ctx.Execute<SystemEdit>(SystemColor, m => m.ShowColor(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemShowColor(var param, var flags) => ctx.Execute<SystemEdit>(SystemColor, m => m.ShowColor(ctx, param.target ?? ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemClearColor(var param, var flags) => ctx.Execute<SystemEdit>(SystemColor, m => m.ClearColor(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemChangeColor(var param, _) => ctx.Execute<SystemEdit>(SystemColor, m => m.ChangeColor(ctx, ctx.System, param.color)),
|
||||
Commands.SystemShowTagSelf(_, var flags) => ctx.Execute<SystemEdit>(SystemTag, m => m.ShowTag(ctx, ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemShowTag(var param, var flags) => ctx.Execute<SystemEdit>(SystemTag, m => m.ShowTag(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemShowTag(var param, var flags) => ctx.Execute<SystemEdit>(SystemTag, m => m.ShowTag(ctx, param.target ?? ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemClearTag(var param, var flags) => ctx.Execute<SystemEdit>(SystemTag, m => m.ClearTag(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemChangeTag(var param, _) => ctx.Execute<SystemEdit>(SystemTag, m => m.ChangeTag(ctx, ctx.System, param.tag)),
|
||||
Commands.SystemShowServerTagSelf(_, var flags) => ctx.Execute<SystemEdit>(SystemServerTag, m => m.ShowServerTag(ctx, ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemShowServerTag(var param, var flags) => ctx.Execute<SystemEdit>(SystemServerTag, m => m.ShowServerTag(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemShowServerTag(var param, var flags) => ctx.Execute<SystemEdit>(SystemServerTag, m => m.ShowServerTag(ctx, param.target ?? ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemClearServerTag(var param, var flags) => ctx.Execute<SystemEdit>(SystemServerTag, m => m.ClearServerTag(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemChangeServerTag(var param, _) => ctx.Execute<SystemEdit>(SystemServerTag, m => m.ChangeServerTag(ctx, ctx.System, param.tag)),
|
||||
Commands.SystemShowPronounsSelf(_, var flags) => ctx.Execute<SystemEdit>(SystemPronouns, m => m.ShowPronouns(ctx, ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemShowPronouns(var param, var flags) => ctx.Execute<SystemEdit>(SystemPronouns, m => m.ShowPronouns(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemShowPronouns(var param, var flags) => ctx.Execute<SystemEdit>(SystemPronouns, m => m.ShowPronouns(ctx, param.target ?? ctx.System, flags.GetReplyFormat())),
|
||||
Commands.SystemClearPronouns(var param, var flags) => ctx.Execute<SystemEdit>(SystemPronouns, m => m.ClearPronouns(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemChangePronouns(var param, _) => ctx.Execute<SystemEdit>(SystemPronouns, m => m.ChangePronouns(ctx, ctx.System, param.pronouns)),
|
||||
Commands.SystemShowAvatarSelf(_, var flags) => ((Func<Task>)(() =>
|
||||
Commands.SystemShowAvatar(var param, var flags) => ((Func<Task>)(() =>
|
||||
{
|
||||
if (param.target == null)
|
||||
{
|
||||
// we want to change avatar if an attached image is passed
|
||||
// we can't have a separate parsed command for this since the parser can't be aware of any attachments
|
||||
var attachedImage = ctx.ExtractImageFromAttachment();
|
||||
if (attachedImage is { } image)
|
||||
return ctx.Execute<SystemEdit>(SystemAvatar, m => m.ChangeAvatar(ctx, ctx.System, image));
|
||||
}
|
||||
// if no attachment show the avatar like intended
|
||||
return ctx.Execute<SystemEdit>(SystemAvatar, m => m.ShowAvatar(ctx, ctx.System, flags.GetReplyFormat()));
|
||||
return ctx.Execute<SystemEdit>(SystemAvatar, m => m.ShowAvatar(ctx, param.target ?? ctx.System, flags.GetReplyFormat()));
|
||||
}))(),
|
||||
Commands.SystemShowAvatar(var param, var flags) => ctx.Execute<SystemEdit>(SystemAvatar, m => m.ShowAvatar(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemClearAvatar(var param, var flags) => ctx.Execute<SystemEdit>(SystemAvatar, m => m.ClearAvatar(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemChangeAvatar(var param, _) => ctx.Execute<SystemEdit>(SystemAvatar, m => m.ChangeAvatar(ctx, ctx.System, param.avatar)),
|
||||
Commands.SystemShowServerAvatarSelf(_, var flags) => ((Func<Task>)(() =>
|
||||
Commands.SystemShowServerAvatar(var param, var flags) => ((Func<Task>)(() =>
|
||||
{
|
||||
if (param.target == null)
|
||||
{
|
||||
// we want to change avatar if an attached image is passed
|
||||
// we can't have a separate parsed command for this since the parser can't be aware of any attachments
|
||||
var attachedImage = ctx.ExtractImageFromAttachment();
|
||||
if (attachedImage is { } image)
|
||||
return ctx.Execute<SystemEdit>(SystemServerAvatar, m => m.ChangeServerAvatar(ctx, ctx.System, image));
|
||||
}
|
||||
// if no attachment show the avatar like intended
|
||||
return ctx.Execute<SystemEdit>(SystemServerAvatar, m => m.ShowServerAvatar(ctx, ctx.System, flags.GetReplyFormat()));
|
||||
return ctx.Execute<SystemEdit>(SystemServerAvatar, m => m.ShowServerAvatar(ctx, param.target ?? ctx.System, flags.GetReplyFormat()));
|
||||
}))(),
|
||||
Commands.SystemShowServerAvatar(var param, var flags) => ctx.Execute<SystemEdit>(SystemServerAvatar, m => m.ShowServerAvatar(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemClearServerAvatar(var param, var flags) => ctx.Execute<SystemEdit>(SystemServerAvatar, m => m.ClearServerAvatar(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemChangeServerAvatar(var param, _) => ctx.Execute<SystemEdit>(SystemServerAvatar, m => m.ChangeServerAvatar(ctx, ctx.System, param.avatar)),
|
||||
Commands.SystemShowBannerSelf(_, var flags) => ((Func<Task>)(() =>
|
||||
Commands.SystemShowBanner(var param, var flags) => ((Func<Task>)(() =>
|
||||
{
|
||||
if (param.target == null)
|
||||
{
|
||||
// we want to change banner if an attached image is passed
|
||||
// we can't have a separate parsed command for this since the parser can't be aware of any attachments
|
||||
var attachedImage = ctx.ExtractImageFromAttachment();
|
||||
if (attachedImage is { } image)
|
||||
return ctx.Execute<SystemEdit>(SystemBannerImage, m => m.ChangeBannerImage(ctx, ctx.System, image));
|
||||
}
|
||||
// if no attachment show the banner like intended
|
||||
return ctx.Execute<SystemEdit>(SystemBannerImage, m => m.ShowBannerImage(ctx, ctx.System, flags.GetReplyFormat()));
|
||||
return ctx.Execute<SystemEdit>(SystemBannerImage, m => m.ShowBannerImage(ctx, param.target ?? ctx.System, flags.GetReplyFormat()));
|
||||
}))(),
|
||||
Commands.SystemShowBanner(var param, var flags) => ctx.Execute<SystemEdit>(SystemBannerImage, m => m.ShowBannerImage(ctx, param.target, flags.GetReplyFormat())),
|
||||
Commands.SystemClearBanner(var param, var flags) => ctx.Execute<SystemEdit>(SystemBannerImage, m => m.ClearBannerImage(ctx, ctx.System, flags.yes)),
|
||||
Commands.SystemChangeBanner(var param, _) => ctx.Execute<SystemEdit>(SystemBannerImage, m => m.ChangeBannerImage(ctx, ctx.System, param.banner)),
|
||||
Commands.SystemDelete(_, var flags) => ctx.Execute<SystemEdit>(SystemDelete, m => m.Delete(ctx, ctx.System, flags.no_export)),
|
||||
|
|
@ -208,14 +205,10 @@ public partial class CommandTree
|
|||
Commands.SwitchEditOut(_, var flags) => ctx.Execute<Switch>(SwitchEditOut, m => m.SwitchEditOut(ctx, flags.yes)),
|
||||
Commands.SwitchDelete(var param, var flags) => ctx.Execute<Switch>(SwitchDelete, m => m.SwitchDelete(ctx, flags.all)),
|
||||
Commands.SwitchCopy(var param, var flags) => ctx.Execute<Switch>(SwitchCopy, m => m.SwitchEdit(ctx, param.targets, true, flags.first, flags.remove, flags.append, flags.prepend)),
|
||||
Commands.SystemFronter(var param, var flags) => ctx.Execute<SystemFront>(SystemFronter, m => m.Fronter(ctx, param.target)),
|
||||
Commands.SystemFronterHistory(var param, var flags) => ctx.Execute<SystemFront>(SystemFrontHistory, m => m.FrontHistory(ctx, param.target, flags.clear)),
|
||||
Commands.SystemFronterPercent(var param, var flags) => ctx.Execute<SystemFront>(SystemFrontPercent, m => m.FrontPercent(ctx, param.target, flags.duration, flags.fronters_only, flags.flat)),
|
||||
Commands.SystemFronterSelf(_, var flags) => ctx.Execute<SystemFront>(SystemFronter, m => m.Fronter(ctx, ctx.System)),
|
||||
Commands.SystemFronterHistorySelf(_, var flags) => ctx.Execute<SystemFront>(SystemFrontHistory, m => m.FrontHistory(ctx, ctx.System, flags.clear)),
|
||||
Commands.SystemFronterPercentSelf(_, var flags) => ctx.Execute<SystemFront>(SystemFrontPercent, m => m.FrontPercent(ctx, ctx.System, flags.duration, flags.fronters_only, flags.flat)),
|
||||
Commands.SystemDisplayId(var param, _) => ctx.Execute<System>(SystemId, m => m.DisplayId(ctx, param.target)),
|
||||
Commands.SystemDisplayIdSelf => ctx.Execute<System>(SystemId, m => m.DisplayId(ctx, ctx.System)),
|
||||
Commands.SystemFronter(var param, var flags) => ctx.Execute<SystemFront>(SystemFronter, m => m.Fronter(ctx, param.target ?? ctx.System)),
|
||||
Commands.SystemFronterHistory(var param, var flags) => ctx.Execute<SystemFront>(SystemFrontHistory, m => m.FrontHistory(ctx, param.target ?? ctx.System, flags.clear)),
|
||||
Commands.SystemFronterPercent(var param, var flags) => ctx.Execute<SystemFront>(SystemFrontPercent, m => m.FrontPercent(ctx, param.target ?? ctx.System, flags.duration, flags.fronters_only, flags.flat)),
|
||||
Commands.SystemDisplayId(var param, _) => ctx.Execute<System>(SystemId, m => m.DisplayId(ctx, param.target ?? ctx.System)),
|
||||
Commands.SystemWebhookShow => ctx.Execute<Api>(null, m => m.GetSystemWebhook(ctx)),
|
||||
Commands.SystemWebhookClear(_, var flags) => ctx.Execute<Api>(null, m => m.ClearSystemWebhook(ctx, flags.yes)),
|
||||
Commands.SystemWebhookSet(var param, _) => ctx.Execute<Api>(null, m => m.SetSystemWebhook(ctx, param.url)),
|
||||
|
|
@ -238,8 +231,7 @@ public partial class CommandTree
|
|||
Commands.SystemMembers(var param, var flags) => ctx.Execute<SystemList>(SystemList, m => m.MemberList(ctx, param.target, param.query, flags)),
|
||||
Commands.MemberGroups(var param, var flags) => ctx.Execute<GroupMember>(MemberGroups, m => m.ListMemberGroups(ctx, param.target, param.query, flags, flags.all)),
|
||||
Commands.GroupMembers(var param, var flags) => ctx.Execute<GroupMember>(GroupMemberList, m => m.ListGroupMembers(ctx, param.target, param.query, flags)),
|
||||
Commands.SystemGroups(var param, var flags) => ctx.Execute<Groups>(GroupList, g => g.ListSystemGroups(ctx, param.target, param.query, flags, flags.all)),
|
||||
Commands.SystemGroupsSelf(var param, var flags) => ctx.Execute<Groups>(GroupList, g => g.ListSystemGroups(ctx, ctx.System, param.query, flags, flags.all)),
|
||||
Commands.SystemGroups(var param, var flags) => ctx.Execute<Groups>(GroupList, g => g.ListSystemGroups(ctx, param.target ?? ctx.System, param.query, flags, flags.all)),
|
||||
Commands.GroupsSelf(var param, var flags) => ctx.Execute<Groups>(GroupList, g => g.ListSystemGroups(ctx, ctx.System, param.query, flags, flags.all)),
|
||||
Commands.GroupNew(var param, _) => ctx.Execute<Groups>(GroupNew, g => g.CreateGroup(ctx, param.name)),
|
||||
Commands.GroupInfo(var param, var flags) => ctx.Execute<Groups>(GroupInfo, g => g.ShowGroupCard(ctx, param.target, flags.show_embed, flags.all)),
|
||||
|
|
|
|||
|
|
@ -22,13 +22,11 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
let system = system();
|
||||
let system_target = targeted();
|
||||
|
||||
let system_new = tokens!(system, ("new", ["n"]));
|
||||
let system_new_cmd = [
|
||||
command!(system_new => "system_new").help("Creates a new system"),
|
||||
command!(system_new, Remainder(("name", OpaqueString)) => "system_new_name")
|
||||
.help("Creates a new system (using the provided name)"),
|
||||
]
|
||||
.into_iter();
|
||||
let system_new_cmd =
|
||||
once(
|
||||
command!(system, ("new", ["n"]), Optional(Remainder(("name", OpaqueString))) => "system_new")
|
||||
.help("Creates a new system")
|
||||
);
|
||||
|
||||
let system_webhook = tokens!(system, ("webhook", ["hook"]));
|
||||
let system_webhook_cmd = [
|
||||
|
|
@ -46,24 +44,22 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
.flag(("private", ["priv"]))
|
||||
.flag(ALL)
|
||||
};
|
||||
let system_info_cmd_self =
|
||||
once(command!(system => "system_info_self").help("Shows information about your system"))
|
||||
.map(add_info_flags);
|
||||
let system_info_cmd = [
|
||||
command!(system_target => "system_info").help("Shows information about your system"),
|
||||
command!(system_target, ("info", ["show", "view"]) => "system_info")
|
||||
command!(system, Optional(SystemRef) => "system_info")
|
||||
.help("Shows information about your system"),
|
||||
command!(system, Optional(SystemRef), ("info", ["show", "view"]) => "system_info")
|
||||
.help("Shows information about your system"),
|
||||
]
|
||||
.into_iter()
|
||||
.map(add_info_flags);
|
||||
|
||||
let system_name = tokens!(system_target, "name");
|
||||
let system_name_cmd =
|
||||
once(command!(system_name => "system_show_name").help("Shows the systems name"));
|
||||
|
||||
let system_name_self = tokens!(system, "name");
|
||||
let name = "name";
|
||||
let system_name_cmd = once(
|
||||
command!(system, Optional(SystemRef), name => "system_show_name")
|
||||
.help("Shows the systems name"),
|
||||
);
|
||||
let system_name_self = tokens!(system, name);
|
||||
let system_name_self_cmd = [
|
||||
command!(system_name_self => "system_show_name_self").help("Shows your system's name"),
|
||||
command!(system_name_self, CLEAR => "system_clear_name")
|
||||
.flag(YES)
|
||||
.help("Clears your system's name"),
|
||||
|
|
@ -72,16 +68,13 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_server_name = tokens!(system_target, ("servername", ["sn", "guildname"]));
|
||||
let server_name = ("servername", ["sn", "guildname"]);
|
||||
let system_server_name_cmd = once(
|
||||
command!(system_server_name => "system_show_server_name")
|
||||
command!(system, Optional(SystemRef), server_name => "system_show_server_name")
|
||||
.help("Shows the system's server name"),
|
||||
);
|
||||
|
||||
let system_server_name_self = tokens!(system, ("servername", ["sn", "guildname"]));
|
||||
let system_server_name_self = tokens!(system, server_name);
|
||||
let system_server_name_self_cmd = [
|
||||
command!(system_server_name_self => "system_show_server_name_self")
|
||||
.help("Shows your system's server name"),
|
||||
command!(system_server_name_self, CLEAR => "system_clear_server_name")
|
||||
.flag(YES)
|
||||
.help("Clears your system's server name"),
|
||||
|
|
@ -90,15 +83,13 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_description = tokens!(system_target, ("description", ["desc", "d"]));
|
||||
let description = ("description", ["desc", "d"]);
|
||||
let system_description_cmd = once(
|
||||
command!(system_description => "system_show_description")
|
||||
command!(system, Optional(SystemRef), description => "system_show_description")
|
||||
.help("Shows the system's description"),
|
||||
);
|
||||
|
||||
let system_description_self = tokens!(system, ("description", ["desc", "d"]));
|
||||
let system_description_self = tokens!(system, description);
|
||||
let system_description_self_cmd = [
|
||||
command!(system_description_self => "system_show_description_self").help("Shows your system's description"),
|
||||
command!(system_description_self, CLEAR => "system_clear_description")
|
||||
.flag(YES)
|
||||
.help("Clears your system's description"),
|
||||
|
|
@ -107,13 +98,13 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_color = tokens!(system_target, ("color", ["colour"]));
|
||||
let system_color_cmd =
|
||||
once(command!(system_color => "system_show_color").help("Shows the system's color"));
|
||||
|
||||
let system_color_self = tokens!(system, ("color", ["colour"]));
|
||||
let color = ("color", ["colour"]);
|
||||
let system_color_cmd = once(
|
||||
command!(system, Optional(SystemRef), color => "system_show_color")
|
||||
.help("Shows the system's color"),
|
||||
);
|
||||
let system_color_self = tokens!(system, color);
|
||||
let system_color_self_cmd = [
|
||||
command!(system_color_self => "system_show_color_self").help("Shows your system's color"),
|
||||
command!(system_color_self, CLEAR => "system_clear_color")
|
||||
.flag(YES)
|
||||
.help("Clears your system's color"),
|
||||
|
|
@ -122,13 +113,13 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_tag = tokens!(system_target, ("tag", ["suffix"]));
|
||||
let system_tag_cmd =
|
||||
once(command!(system_tag => "system_show_tag").help("Shows the system's tag"));
|
||||
|
||||
let system_tag_self = tokens!(system, ("tag", ["suffix"]));
|
||||
let tag = ("tag", ["suffix"]);
|
||||
let system_tag_cmd = once(
|
||||
command!(system, Optional(SystemRef), tag => "system_show_tag")
|
||||
.help("Shows the system's tag"),
|
||||
);
|
||||
let system_tag_self = tokens!(system, tag);
|
||||
let system_tag_self_cmd = [
|
||||
command!(system_tag_self => "system_show_tag_self").help("Shows your system's tag"),
|
||||
command!(system_tag_self, CLEAR => "system_clear_tag")
|
||||
.flag(YES)
|
||||
.help("Clears your system's tag"),
|
||||
|
|
@ -137,16 +128,13 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_server_tag = tokens!(system_target, ("servertag", ["st", "guildtag"]));
|
||||
let servertag = ("servertag", ["st", "guildtag"]);
|
||||
let system_server_tag_cmd = once(
|
||||
command!(system_server_tag => "system_show_server_tag")
|
||||
command!(system, Optional(SystemRef) => "system_show_server_tag")
|
||||
.help("Shows the system's server tag"),
|
||||
);
|
||||
|
||||
let system_server_tag_self = tokens!(system, ("servertag", ["st", "guildtag"]));
|
||||
let system_server_tag_self = tokens!(system, servertag);
|
||||
let system_server_tag_self_cmd = [
|
||||
command!(system_server_tag_self => "system_show_server_tag_self")
|
||||
.help("Shows your system's server tag"),
|
||||
command!(system_server_tag_self, CLEAR => "system_clear_server_tag")
|
||||
.flag(YES)
|
||||
.help("Clears your system's server tag"),
|
||||
|
|
@ -155,15 +143,13 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_pronouns = tokens!(system_target, ("pronouns", ["prns"]));
|
||||
let pronouns = ("pronouns", ["prns"]);
|
||||
let system_pronouns_cmd = once(
|
||||
command!(system_pronouns => "system_show_pronouns").help("Shows the system's pronouns"),
|
||||
command!(system, Optional(SystemRef), pronouns => "system_show_pronouns")
|
||||
.help("Shows the system's pronouns"),
|
||||
);
|
||||
|
||||
let system_pronouns_self = tokens!(system, ("pronouns", ["prns"]));
|
||||
let system_pronouns_self = tokens!(system, pronouns);
|
||||
let system_pronouns_self_cmd = [
|
||||
command!(system_pronouns_self => "system_show_pronouns_self")
|
||||
.help("Shows your system's pronouns"),
|
||||
command!(system_pronouns_self, CLEAR => "system_clear_pronouns")
|
||||
.flag(YES)
|
||||
.help("Clears your system's pronouns"),
|
||||
|
|
@ -172,14 +158,13 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_avatar = tokens!(system_target, ("avatar", ["pfp"]));
|
||||
let system_avatar_cmd =
|
||||
once(command!(system_avatar => "system_show_avatar").help("Shows the system's avatar"));
|
||||
|
||||
let system_avatar_self = tokens!(system, ("avatar", ["pfp"]));
|
||||
let avatar = ("avatar", ["pfp"]);
|
||||
let system_avatar_cmd = once(
|
||||
command!(system, Optional(SystemRef), avatar => "system_show_avatar")
|
||||
.help("Shows the system's avatar"),
|
||||
);
|
||||
let system_avatar_self = tokens!(system, avatar);
|
||||
let system_avatar_self_cmd = [
|
||||
command!(system_avatar_self => "system_show_avatar_self")
|
||||
.help("Shows your system's avatar"),
|
||||
command!(system_avatar_self, CLEAR => "system_clear_avatar")
|
||||
.flag(YES)
|
||||
.help("Clears your system's avatar"),
|
||||
|
|
@ -188,16 +173,14 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_server_avatar = tokens!(system_target, ("serveravatar", ["spfp"]));
|
||||
let serveravatar = ("serveravatar", ["spfp"]);
|
||||
let system_server_avatar = tokens!(system_target, serveravatar);
|
||||
let system_server_avatar_cmd = once(
|
||||
command!(system_server_avatar => "system_show_server_avatar")
|
||||
command!(system, Optional(SystemRef), serveravatar => "system_show_server_avatar")
|
||||
.help("Shows the system's server avatar"),
|
||||
);
|
||||
|
||||
let system_server_avatar_self = tokens!(system, ("serveravatar", ["spfp"]));
|
||||
let system_server_avatar_self = tokens!(system, serveravatar);
|
||||
let system_server_avatar_self_cmd = [
|
||||
command!(system_server_avatar_self => "system_show_server_avatar_self")
|
||||
.help("Shows your system's server avatar"),
|
||||
command!(system_server_avatar_self, CLEAR => "system_clear_server_avatar")
|
||||
.flag(YES)
|
||||
.help("Clears your system's server avatar"),
|
||||
|
|
@ -206,14 +189,13 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_banner = tokens!(system_target, ("banner", ["cover"]));
|
||||
let system_banner_cmd =
|
||||
once(command!(system_banner => "system_show_banner").help("Shows the system's banner"));
|
||||
|
||||
let system_banner_self = tokens!(system, ("banner", ["cover"]));
|
||||
let banner = ("banner", ["cover"]);
|
||||
let system_banner_cmd = once(
|
||||
command!(system, Optional(SystemRef), banner => "system_show_banner")
|
||||
.help("Shows the system's banner"),
|
||||
);
|
||||
let system_banner_self = tokens!(system, banner);
|
||||
let system_banner_self_cmd = [
|
||||
command!(system_banner_self => "system_show_banner_self")
|
||||
.help("Shows your system's banner"),
|
||||
command!(system_banner_self, CLEAR => "system_clear_banner")
|
||||
.flag(YES)
|
||||
.help("Clears your system's banner"),
|
||||
|
|
@ -222,12 +204,6 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
]
|
||||
.into_iter();
|
||||
|
||||
let system_delete = once(
|
||||
command!(system, ("delete", ["erase", "remove", "yeet"]) => "system_delete")
|
||||
.flag(("no-export", ["ne"]))
|
||||
.help("Deletes the system"),
|
||||
);
|
||||
|
||||
let system_proxy = tokens!(system, "proxy");
|
||||
let system_proxy_cmd = [
|
||||
command!(system_proxy => "system_show_proxy_current")
|
||||
|
|
@ -252,32 +228,22 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
].into_iter();
|
||||
|
||||
let front = ("front", ["fronter", "fronters", "f"]);
|
||||
let make_system_front_cmd = |prefix: TokensIterator, suffix: &str| {
|
||||
let make_front_history = |subcmd: TokensIterator| {
|
||||
command!(prefix, subcmd => format!("system_fronter_history{}", suffix)).flag(CLEAR)
|
||||
command!(system, Optional(SystemRef), subcmd => "system_fronter_history").flag(CLEAR)
|
||||
};
|
||||
let make_front_percent = |subcmd: TokensIterator| {
|
||||
command!(prefix, subcmd => format!("system_fronter_percent{}", suffix))
|
||||
command!(system, Optional(SystemRef), subcmd => "system_fronter_percent")
|
||||
.flag(("duration", OpaqueString))
|
||||
.flag(("fronters-only", ["fo"]))
|
||||
.flag("flat")
|
||||
};
|
||||
[
|
||||
command!(prefix, front => format!("system_fronter{}", suffix)),
|
||||
let system_front_cmd = [
|
||||
command!(system, Optional(SystemRef), front => "system_fronter"),
|
||||
make_front_history(tokens!(front, ("history", ["h"]))),
|
||||
make_front_history(tokens!(("fronthistory", ["fh"]))),
|
||||
make_front_percent(tokens!(front, ("percent", ["p", "%"]))),
|
||||
make_front_percent(tokens!(("frontpercent", ["fp"]))),
|
||||
]
|
||||
.into_iter()
|
||||
};
|
||||
let system_front_cmd = make_system_front_cmd(tokens!(system_target), "");
|
||||
let system_front_self_cmd = make_system_front_cmd(tokens!(system), "_self");
|
||||
|
||||
let system_link = [
|
||||
command!("link", ("account", UserRef) => "system_link"),
|
||||
command!("unlink", ("account", OpaqueString) => "system_unlink").flag(YES),
|
||||
]
|
||||
.into_iter();
|
||||
|
||||
let search_param = Optional(Remainder(("query", OpaqueString)));
|
||||
|
|
@ -285,25 +251,31 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
|
||||
let members_subcmd = tokens!(("members", ["ls", "list"]), search_param);
|
||||
let system_members_cmd =
|
||||
once(command!(system_target, members_subcmd => "system_members")).map(apply_list_opts);
|
||||
let system_members_self_cmd = [
|
||||
command!(system, members_subcmd => "system_members_self"),
|
||||
command!(members_subcmd => "system_members_self"),
|
||||
]
|
||||
.into_iter()
|
||||
once(command!(system, Optional(SystemRef), members_subcmd => "system_members"))
|
||||
.map(apply_list_opts);
|
||||
let system_members_self_cmd =
|
||||
once(command!(members_subcmd => "system_members_self")).map(apply_list_opts);
|
||||
|
||||
let system_groups_cmd =
|
||||
once(command!(system, Optional(SystemRef), "groups", search_param => "system_groups"))
|
||||
.map(apply_list_opts);
|
||||
|
||||
let groups_subcmd = tokens!("groups", search_param);
|
||||
let system_groups_cmd =
|
||||
once(command!(system_target, groups_subcmd => "system_groups")).map(apply_list_opts);
|
||||
let system_group_self_cmd =
|
||||
once(command!(system, groups_subcmd => "system_groups_self")).map(apply_list_opts);
|
||||
let system_display_id_cmd =
|
||||
once(command!(system, Optional(SystemRef), "id" => "system_display_id"));
|
||||
|
||||
let system_display_id_self_cmd = once(command!(system, "id" => "system_display_id_self"));
|
||||
let system_display_id_cmd = once(command!(system_target, "id" => "system_display_id"));
|
||||
let system_delete = once(
|
||||
command!(system, ("delete", ["erase", "remove", "yeet"]) => "system_delete")
|
||||
.flag(("no-export", ["ne"]))
|
||||
.help("Deletes the system"),
|
||||
);
|
||||
|
||||
system_info_cmd_self
|
||||
.chain(system_new_cmd)
|
||||
let system_link = [
|
||||
command!("link", ("account", UserRef) => "system_link"),
|
||||
command!("unlink", ("account", OpaqueString) => "system_unlink").flag(YES),
|
||||
]
|
||||
.into_iter();
|
||||
|
||||
system_new_cmd
|
||||
.chain(system_webhook_cmd)
|
||||
.chain(system_name_self_cmd)
|
||||
.chain(system_server_name_self_cmd)
|
||||
|
|
@ -316,9 +288,6 @@ pub fn edit() -> impl Iterator<Item = Command> {
|
|||
.chain(system_server_avatar_self_cmd)
|
||||
.chain(system_banner_self_cmd)
|
||||
.chain(system_members_self_cmd)
|
||||
.chain(system_group_self_cmd)
|
||||
.chain(system_display_id_self_cmd)
|
||||
.chain(system_front_self_cmd)
|
||||
.chain(system_delete)
|
||||
.chain(system_privacy_cmd)
|
||||
.chain(system_proxy_cmd)
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ impl<P: Into<Parameter>> From<Remainder<P>> for Parameter {
|
|||
}
|
||||
}
|
||||
|
||||
// todo: this should ideally be removed in favor of making Token::Parameter take multiple parameters
|
||||
/// skips the branch this parameter is in if it does not match
|
||||
#[derive(Clone)]
|
||||
pub struct Skip<P: Into<Parameter>>(pub P);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue