cleanup unneeded .into_iters() and stuff

This commit is contained in:
dawn 2026-01-17 10:25:22 +03:00
parent 553b566595
commit d1451a858d
No known key found for this signature in database
17 changed files with 82 additions and 146 deletions

View file

@ -4,7 +4,7 @@ pub fn admin() -> &'static str {
"admin" "admin"
} }
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
let admin = admin(); let admin = admin();
let abuselog = tokens!(admin, ("abuselog", ["al"])); let abuselog = tokens!(admin, ("abuselog", ["al"]));
@ -24,7 +24,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Removes a user from an abuse log entry"), .help("Removes a user from an abuse log entry"),
command!(abuselog, ("delete", ["d"]), log_param => format!("admin_abuselog_delete_{}", log_param.name())) command!(abuselog, ("delete", ["d"]), log_param => format!("admin_abuselog_delete_{}", log_param.name()))
.help("Deletes an abuse log entry"), .help("Deletes an abuse log entry"),
].into_iter() ]
}; };
let abuselog_cmds = [ let abuselog_cmds = [
command!(abuselog, ("create", ["c", "new"]), ("account", UserRef), Optional(Remainder(("description", OpaqueString))) => "admin_abuselog_create") command!(abuselog, ("create", ["c", "new"]), ("account", UserRef), Optional(Remainder(("description", OpaqueString))) => "admin_abuselog_create")

View file

@ -1,9 +1,8 @@
use super::*; use super::*;
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
[ [
command!("token" => "token_display"), command!("token" => "token_display"),
command!("token", ("refresh", ["renew", "regen", "reroll"]) => "token_refresh"), command!("token", ("refresh", ["renew", "regen", "reroll"]) => "token_refresh"),
] ]
.into_iter()
} }

View file

@ -4,7 +4,7 @@ pub fn autoproxy() -> (&'static str, [&'static str; 2]) {
("autoproxy", ["ap", "auto"]) ("autoproxy", ["ap", "auto"])
} }
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
let ap = autoproxy(); let ap = autoproxy();
[ [
@ -17,5 +17,4 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Sets autoproxy to front mode"), .help("Sets autoproxy to front mode"),
command!(ap, MemberRef => "autoproxy_member").help("Sets autoproxy to a specific member"), command!(ap, MemberRef => "autoproxy_member").help("Sets autoproxy to a specific member"),
] ]
.into_iter()
} }

View file

@ -2,7 +2,7 @@ use command_parser::parameter;
use super::*; use super::*;
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
let cfg = ("config", ["cfg", "configure"]); let cfg = ("config", ["cfg", "configure"]);
let ap = tokens!(cfg, ("autoproxy", ["ap"])); let ap = tokens!(cfg, ("autoproxy", ["ap"]));
@ -198,5 +198,4 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(group_limit => "cfg_limits_update").help("Refreshes member/group limits"), command!(group_limit => "cfg_limits_update").help("Refreshes member/group limits"),
command!(limit => "cfg_limits_update").help("Refreshes member/group limits"), command!(limit => "cfg_limits_update").help("Refreshes member/group limits"),
] ]
.into_iter()
} }

View file

@ -4,7 +4,7 @@ pub fn debug() -> (&'static str, [&'static str; 1]) {
("debug", ["dbg"]) ("debug", ["dbg"])
} }
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
let debug = debug(); let debug = debug();
let perms = ("permissions", ["perms", "permcheck"]); let perms = ("permissions", ["perms", "permcheck"]);
[ [
@ -12,5 +12,4 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(debug, perms, ("guild", ["g"]), GuildRef => "permcheck_guild"), command!(debug, perms, ("guild", ["g"]), GuildRef => "permcheck_guild"),
command!(debug, ("proxy", ["proxying", "proxycheck"]), MessageRef => "message_proxy_check"), command!(debug, ("proxy", ["proxying", "proxycheck"]), MessageRef => "message_proxy_check"),
] ]
.into_iter()
} }

View file

@ -1,6 +1,6 @@
use super::*; use super::*;
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
[ [
command!("thunder" => "fun_thunder"), command!("thunder" => "fun_thunder"),
command!("meow" => "fun_meow"), command!("meow" => "fun_meow"),
@ -13,5 +13,4 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!("sus" => "amogus"), command!("sus" => "amogus"),
command!("error" => "fun_error"), command!("error" => "fun_error"),
] ]
.into_iter()
} }

View file

@ -19,16 +19,16 @@ pub fn cmds() -> impl Iterator<Item = Command> {
let group_target = targeted(); let group_target = targeted();
let group_new = tokens!(group, ("new", ["n"])); let group_new = tokens!(group, ("new", ["n"]));
let group_new_cmd = [ let group_new_cmd = once(
command!(group_new, Remainder(("name", OpaqueString)) => "group_new") command!(group_new, Remainder(("name", OpaqueString)) => "group_new")
.help("Creates a new group"), .help("Creates a new group"),
] );
.into_iter();
let group_info_cmd = [command!(group_target => "group_info") let group_info_cmd = once(
.flag(ALL) command!(group_target => "group_info")
.help("Shows information about a group")] .flag(ALL)
.into_iter(); .help("Shows information about a group"),
);
let group_name = tokens!( let group_name = tokens!(
group_target, group_target,
@ -41,8 +41,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Clears the group's name"), .help("Clears the group's name"),
command!(group_name, Remainder(("name", OpaqueString)) => "group_rename") command!(group_name, Remainder(("name", OpaqueString)) => "group_rename")
.help("Renames the group"), .help("Renames the group"),
] ];
.into_iter();
let group_display_name = tokens!(group_target, ("displayname", ["dn", "nick", "nickname"])); let group_display_name = tokens!(group_target, ("displayname", ["dn", "nick", "nickname"]));
let group_display_name_cmd = [ let group_display_name_cmd = [
@ -53,8 +52,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Clears the group's display name"), .help("Clears the group's display name"),
command!(group_display_name, Remainder(("name", OpaqueString)) => "group_change_display_name") command!(group_display_name, Remainder(("name", OpaqueString)) => "group_change_display_name")
.help("Changes the group's display name"), .help("Changes the group's display name"),
] ];
.into_iter();
let group_description = tokens!( let group_description = tokens!(
group_target, group_target,
@ -71,8 +69,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Clears the group's description"), .help("Clears the group's description"),
command!(group_description, Remainder(("description", OpaqueString)) => "group_change_description") command!(group_description, Remainder(("description", OpaqueString)) => "group_change_description")
.help("Changes the group's description"), .help("Changes the group's description"),
] ];
.into_iter();
let group_icon = tokens!( let group_icon = tokens!(
group_target, group_target,
@ -85,8 +82,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Clears the group's icon"), .help("Clears the group's icon"),
command!(group_icon, ("icon", Avatar) => "group_change_icon") command!(group_icon, ("icon", Avatar) => "group_change_icon")
.help("Changes the group's icon"), .help("Changes the group's icon"),
] ];
.into_iter();
let group_banner = tokens!(group_target, ("banner", ["splash", "cover"])); let group_banner = tokens!(group_target, ("banner", ["splash", "cover"]));
let group_banner_cmd = [ let group_banner_cmd = [
@ -96,8 +92,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Clears the group's banner"), .help("Clears the group's banner"),
command!(group_banner, ("banner", Avatar) => "group_change_banner") command!(group_banner, ("banner", Avatar) => "group_change_banner")
.help("Changes the group's banner"), .help("Changes the group's banner"),
] ];
.into_iter();
let group_color = tokens!(group_target, ("color", ["colour"])); let group_color = tokens!(group_target, ("color", ["colour"]));
let group_color_cmd = [ let group_color_cmd = [
@ -107,8 +102,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Clears the group's color"), .help("Clears the group's color"),
command!(group_color, ("color", OpaqueString) => "group_change_color") command!(group_color, ("color", OpaqueString) => "group_change_color")
.help("Changes the group's color"), .help("Changes the group's color"),
] ];
.into_iter();
let group_privacy = tokens!(group_target, ("privacy", ["priv"])); let group_privacy = tokens!(group_target, ("privacy", ["priv"]));
let group_privacy_cmd = [ let group_privacy_cmd = [
@ -118,30 +112,25 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Changes all privacy settings for the group"), .help("Changes all privacy settings for the group"),
command!(group_privacy, ("privacy", GroupPrivacyTarget), ("level", PrivacyLevel) => "group_change_privacy") command!(group_privacy, ("privacy", GroupPrivacyTarget), ("level", PrivacyLevel) => "group_change_privacy")
.help("Changes a specific privacy setting for the group"), .help("Changes a specific privacy setting for the group"),
] ];
.into_iter();
let group_public_cmd = [ let group_public_cmd = [
command!(group_target, ("public", ["pub"]) => "group_set_public") command!(group_target, ("public", ["pub"]) => "group_set_public")
.help("Sets the group to public"), .help("Sets the group to public"),
] ];
.into_iter();
let group_private_cmd = [ let group_private_cmd = [
command!(group_target, ("private", ["priv"]) => "group_set_private") command!(group_target, ("private", ["priv"]) => "group_set_private")
.help("Sets the group to private"), .help("Sets the group to private"),
] ];
.into_iter();
let group_delete_cmd = [ let group_delete_cmd = [
command!(group_target, ("delete", ["destroy", "erase", "yeet"]) => "group_delete") command!(group_target, ("delete", ["destroy", "erase", "yeet"]) => "group_delete")
.flag(YES) .flag(YES)
.help("Deletes the group"), .help("Deletes the group"),
] ];
.into_iter();
let group_id_cmd = let group_id_cmd = [command!(group_target, "id" => "group_id").help("Shows the group's ID")];
[command!(group_target, "id" => "group_id").help("Shows the group's ID")].into_iter();
let group_front = tokens!(group_target, ("front", ["fronter", "fronters", "f"])); let group_front = tokens!(group_target, ("front", ["fronter", "fronters", "f"]));
let group_front_cmd = [ let group_front_cmd = [
@ -149,8 +138,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(("duration", OpaqueString)) .flag(("duration", OpaqueString))
.flag(("fronters-only", ["fo"])) .flag(("fronters-only", ["fo"]))
.flag("flat"), .flag("flat"),
] ];
.into_iter();
let apply_list_opts = |cmd: Command| cmd.flags(get_list_flags()); let apply_list_opts = |cmd: Command| cmd.flags(get_list_flags());
let search_param = Optional(Remainder(("query", OpaqueString))); let search_param = Optional(Remainder(("query", OpaqueString)));
@ -164,8 +152,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(ALL).flag(YES), .flag(ALL).flag(YES),
command!(group_target, ("remove", ["rem", "rm"]), Optional(MemberRefs) => "group_remove_member") command!(group_target, ("remove", ["rem", "rm"]), Optional(MemberRefs) => "group_remove_member")
.flag(ALL).flag(YES), .flag(ALL).flag(YES),
] ];
.into_iter();
let system_groups_cmd = let system_groups_cmd =
once(command!(group, ("list", ["ls", "l"]), search_param => "groups_self")) once(command!(group, ("list", ["ls", "l"]), search_param => "groups_self"))

View file

@ -1,6 +1,6 @@
use super::*; use super::*;
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
let help = ("help", ["h"]); let help = ("help", ["h"]);
[ [
command!(("commands", ["cmd", "c"]), ("subject", OpaqueString) => "commands_list"), command!(("commands", ["cmd", "c"]), ("subject", OpaqueString) => "commands_list"),
@ -10,5 +10,4 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(help, "commands" => "help_commands").help("help commands"), command!(help, "commands" => "help_commands").help("help commands"),
command!(help, "proxy" => "help_proxy").help("help proxy"), command!(help, "proxy" => "help_proxy").help("help proxy"),
] ]
.into_iter()
} }

View file

@ -1,9 +1,8 @@
use super::*; use super::*;
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
[ [
command!("import", Optional(Remainder(("url", OpaqueString))) => "import").flag(YES), command!("import", Optional(Remainder(("url", OpaqueString))) => "import").flag(YES),
command!("export" => "export"), command!("export" => "export"),
] ]
.into_iter()
} }

View file

@ -25,7 +25,8 @@ use command_parser::{
}; };
pub fn all() -> impl Iterator<Item = Command> { pub fn all() -> impl Iterator<Item = Command> {
(help::cmds()) std::iter::empty()
.chain(help::cmds())
.chain(system::cmds()) .chain(system::cmds())
.chain(group::cmds()) .chain(group::cmds())
.chain(member::cmds()) .chain(member::cmds())

View file

@ -35,16 +35,16 @@ pub fn cmds() -> impl Iterator<Item = Command> {
let tts = ("tts", ["texttospeech"]); let tts = ("tts", ["texttospeech"]);
let delete = ("delete", ["del", "remove"]); let delete = ("delete", ["del", "remove"]);
let member_new_cmd = [ let member_new_cmd = once(
command!(member, new, ("name", OpaqueString) => "member_new") command!(member, new, ("name", OpaqueString) => "member_new")
.help("Creates a new system member"), .help("Creates a new system member"),
] );
.into_iter();
let member_info_cmd = [command!(member_target => "member_show") let member_info_cmd = once(
.flag("pt") command!(member_target => "member_show")
.help("Shows information about a member")] .flag("pt")
.into_iter(); .help("Shows information about a member"),
);
let member_name_cmd = { let member_name_cmd = {
let member_name = tokens!(member_target, name); let member_name = tokens!(member_target, name);
@ -54,7 +54,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(YES) .flag(YES)
.help("Changes a member's name"), .help("Changes a member's name"),
] ]
.into_iter()
}; };
let member_description_cmd = { let member_description_cmd = {
@ -67,7 +66,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(member_desc, Remainder(("description", OpaqueString)) => "member_desc_update") command!(member_desc, Remainder(("description", OpaqueString)) => "member_desc_update")
.help("Changes a member's description"), .help("Changes a member's description"),
] ]
.into_iter()
}; };
let member_privacy_cmd = { let member_privacy_cmd = {
@ -81,7 +79,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
) )
.help("Changes a member's privacy settings"), .help("Changes a member's privacy settings"),
] ]
.into_iter()
}; };
let member_pronouns_cmd = { let member_pronouns_cmd = {
@ -94,7 +91,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(member_pronouns, CLEAR => "member_pronouns_clear") command!(member_pronouns, CLEAR => "member_pronouns_clear")
.flag(YES) .flag(YES)
.help("Clears a member's pronouns"), .help("Clears a member's pronouns"),
].into_iter() ]
}; };
let member_banner_cmd = { let member_banner_cmd = {
@ -107,7 +104,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(YES) .flag(YES)
.help("Clears a member's banner image"), .help("Clears a member's banner image"),
] ]
.into_iter()
}; };
let member_color_cmd = { let member_color_cmd = {
@ -120,7 +116,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(YES) .flag(YES)
.help("Clears a member's color"), .help("Clears a member's color"),
] ]
.into_iter()
}; };
let member_birthday_cmd = { let member_birthday_cmd = {
@ -133,7 +128,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(YES) .flag(YES)
.help("Clears a member's birthday"), .help("Clears a member's birthday"),
] ]
.into_iter()
}; };
let member_display_name_cmd = { let member_display_name_cmd = {
@ -146,7 +140,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(member_display_name, CLEAR => "member_displayname_clear") command!(member_display_name, CLEAR => "member_displayname_clear")
.flag(YES) .flag(YES)
.help("Clears a member's display name"), .help("Clears a member's display name"),
].into_iter() ]
}; };
let member_server_name_cmd = { let member_server_name_cmd = {
@ -159,7 +153,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(member_server_name, CLEAR => "member_servername_clear") command!(member_server_name, CLEAR => "member_servername_clear")
.flag(YES) .flag(YES)
.help("Clears a member's server name"), .help("Clears a member's server name"),
].into_iter() ]
}; };
let member_proxy_cmd = { let member_proxy_cmd = {
@ -176,7 +170,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Clears all proxy tags from a member"), .help("Clears all proxy tags from a member"),
command!(member_proxy, Remainder(("tags", OpaqueString)) => "member_proxy_set") command!(member_proxy, Remainder(("tags", OpaqueString)) => "member_proxy_set")
.help("Sets a member's proxy tags"), .help("Sets a member's proxy tags"),
].into_iter() ]
}; };
let member_proxy_settings_cmd = { let member_proxy_settings_cmd = {
@ -194,7 +188,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Clears a member's server-specific keep-proxy setting"), .help("Clears a member's server-specific keep-proxy setting"),
command!(member_server_keep_proxy, ("value", Toggle) => "member_server_keepproxy_update") command!(member_server_keep_proxy, ("value", Toggle) => "member_server_keepproxy_update")
.help("Changes a member's server-specific keep-proxy setting"), .help("Changes a member's server-specific keep-proxy setting"),
].into_iter() ]
}; };
let member_message_settings_cmd = { let member_message_settings_cmd = {
@ -210,7 +204,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(member_autoproxy, ("value", Toggle) => "member_autoproxy_update") command!(member_autoproxy, ("value", Toggle) => "member_autoproxy_update")
.help("Changes whether a member can be autoproxied"), .help("Changes whether a member can be autoproxied"),
] ]
.into_iter()
}; };
let member_avatar_cmd = { let member_avatar_cmd = {
@ -229,7 +222,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(YES) .flag(YES)
.help("Clears a member's avatar"), .help("Clears a member's avatar"),
] ]
.into_iter()
}; };
let member_webhook_avatar_cmd = { let member_webhook_avatar_cmd = {
@ -256,7 +248,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(YES) .flag(YES)
.help("Clears a member's proxy avatar"), .help("Clears a member's proxy avatar"),
] ]
.into_iter()
}; };
let member_server_avatar_cmd = { let member_server_avatar_cmd = {
@ -289,13 +280,8 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(YES) .flag(YES)
.help("Clears a member's server-specific avatar"), .help("Clears a member's server-specific avatar"),
] ]
.into_iter()
}; };
let member_avatar_cmds = member_avatar_cmd
.chain(member_webhook_avatar_cmd)
.chain(member_server_avatar_cmd);
let member_group = tokens!(member_target, ("groups", ["group"])); let member_group = tokens!(member_target, ("groups", ["group"]));
let member_list_group_cmds = once( let member_list_group_cmds = once(
command!(member_group, Optional(Remainder(("query", OpaqueString))) => "member_groups"), command!(member_group, Optional(Remainder(("query", OpaqueString))) => "member_groups"),
@ -306,18 +292,16 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Adds a member to one or more groups"), .help("Adds a member to one or more groups"),
command!(member_group, ("remove", ["rem"]), Optional(("groups", GroupRefs)) => "member_group_remove") command!(member_group, ("remove", ["rem"]), Optional(("groups", GroupRefs)) => "member_group_remove")
.help("Removes a member from one or more groups"), .help("Removes a member from one or more groups"),
] ];
.into_iter();
let member_display_id_cmd = let member_display_id_cmd =
[command!(member_target, "id" => "member_id").help("Displays a member's ID")].into_iter(); [command!(member_target, "id" => "member_id").help("Displays a member's ID")];
let member_delete_cmd = let member_delete_cmd =
[command!(member_target, delete => "member_delete").help("Deletes a member")].into_iter(); [command!(member_target, delete => "member_delete").help("Deletes a member")];
let member_easter_eggs = let member_easter_eggs =
[command!(member_target, "soulscream" => "member_soulscream").show_in_suggestions(false)] [command!(member_target, "soulscream" => "member_soulscream").show_in_suggestions(false)];
.into_iter();
member_new_cmd member_new_cmd
.chain(member_info_cmd) .chain(member_info_cmd)
@ -331,7 +315,9 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.chain(member_display_name_cmd) .chain(member_display_name_cmd)
.chain(member_server_name_cmd) .chain(member_server_name_cmd)
.chain(member_proxy_cmd) .chain(member_proxy_cmd)
.chain(member_avatar_cmds) .chain(member_avatar_cmd)
.chain(member_webhook_avatar_cmd)
.chain(member_server_avatar_cmd)
.chain(member_proxy_settings_cmd) .chain(member_proxy_settings_cmd)
.chain(member_message_settings_cmd) .chain(member_message_settings_cmd)
.chain(member_display_id_cmd) .chain(member_display_id_cmd)

View file

@ -1,6 +1,6 @@
use super::*; use super::*;
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
let message = tokens!(("message", ["msg", "messageinfo"]), Optional(MessageRef)); let message = tokens!(("message", ["msg", "messageinfo"]), Optional(MessageRef));
let author = ("author", ["sender", "a"]); let author = ("author", ["sender", "a"]);
@ -31,5 +31,4 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.flag(author) .flag(author)
.help("Shows information about a proxied message"), .help("Shows information about a proxied message"),
] ]
.into_iter()
} }

View file

@ -1,10 +1,9 @@
use super::*; use super::*;
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
[ [
command!("invite" => "invite").help("Gets a link to invite PluralKit to other servers"), command!("invite" => "invite").help("Gets a link to invite PluralKit to other servers"),
command!(("stats", ["status"]) => "stats") command!(("stats", ["status"]) => "stats")
.help("Shows statistics and information about PluralKit"), .help("Shows statistics and information about PluralKit"),
] ]
.into_iter()
} }

View file

@ -1,3 +1,5 @@
use std::iter::once;
use super::*; use super::*;
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl Iterator<Item = Command> {
@ -44,7 +46,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
let add = ("add", ["enable", "on", "deny"]); let add = ("add", ["enable", "on", "deny"]);
let remove = ("remove", ["disable", "off", "allow"]); let remove = ("remove", ["disable", "off", "allow"]);
// Log channel commands
let log_channel_cmds = [ let log_channel_cmds = [
command!(log_channel => "server_config_log_channel_show") command!(log_channel => "server_config_log_channel_show")
.help("Shows the current log channel"), .help("Shows the current log channel"),
@ -53,10 +54,8 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(log_channel, CLEAR => "server_config_log_channel_clear") command!(log_channel, CLEAR => "server_config_log_channel_clear")
.flag(YES) .flag(YES)
.help("Clears the log channel"), .help("Clears the log channel"),
] ];
.into_iter();
// Log cleanup commands
let log_cleanup_cmds = [ let log_cleanup_cmds = [
command!(log_cleanup => "server_config_log_cleanup_show") command!(log_cleanup => "server_config_log_cleanup_show")
.help("Shows whether log cleanup is enabled"), .help("Shows whether log cleanup is enabled"),
@ -66,10 +65,8 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Shows whether log cleanup is enabled"), .help("Shows whether log cleanup is enabled"),
command!(log_cleanup_short, Toggle => "server_config_log_cleanup_set") command!(log_cleanup_short, Toggle => "server_config_log_cleanup_set")
.help("Enables or disables log cleanup"), .help("Enables or disables log cleanup"),
] ];
.into_iter();
// Log blacklist commands
let log_blacklist_cmds = [ let log_blacklist_cmds = [
command!(log_blacklist => "server_config_log_blacklist_show") command!(log_blacklist => "server_config_log_blacklist_show")
.help("Shows channels where logging is disabled"), .help("Shows channels where logging is disabled"),
@ -79,10 +76,8 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(log_blacklist, remove, Optional(("channel", ChannelRef)) => "server_config_log_blacklist_remove") command!(log_blacklist, remove, Optional(("channel", ChannelRef)) => "server_config_log_blacklist_remove")
.flag(ALL) .flag(ALL)
.help("Removes a channel (or all channels with --all) from the log blacklist"), .help("Removes a channel (or all channels with --all) from the log blacklist"),
] ];
.into_iter();
// Proxy blacklist commands
let proxy_blacklist_cmds = [ let proxy_blacklist_cmds = [
command!(proxy_blacklist => "server_config_proxy_blacklist_show") command!(proxy_blacklist => "server_config_proxy_blacklist_show")
.help("Shows channels where proxying is disabled"), .help("Shows channels where proxying is disabled"),
@ -92,10 +87,8 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(proxy_blacklist, remove, Optional(("channel", ChannelRef)) => "server_config_proxy_blacklist_remove") command!(proxy_blacklist, remove, Optional(("channel", ChannelRef)) => "server_config_proxy_blacklist_remove")
.flag(ALL) .flag(ALL)
.help("Removes a channel (or all channels with --all) from the proxy blacklist"), .help("Removes a channel (or all channels with --all) from the proxy blacklist"),
] ];
.into_iter();
// Invalid command error commands
let invalid_cmds = [ let invalid_cmds = [
command!(invalid => "server_config_invalid_command_response_show") command!(invalid => "server_config_invalid_command_response_show")
.help("Shows whether error responses for invalid commands are enabled"), .help("Shows whether error responses for invalid commands are enabled"),
@ -105,10 +98,8 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Shows whether error responses for invalid commands are enabled"), .help("Shows whether error responses for invalid commands are enabled"),
command!(invalid_short, Toggle => "server_config_invalid_command_response_set") command!(invalid_short, Toggle => "server_config_invalid_command_response_set")
.help("Enables or disables error responses for invalid commands"), .help("Enables or disables error responses for invalid commands"),
] ];
.into_iter();
// Require system tag commands
let require_tag_cmds = [ let require_tag_cmds = [
command!(require_tag => "server_config_require_system_tag_show") command!(require_tag => "server_config_require_system_tag_show")
.help("Shows whether system tags are required"), .help("Shows whether system tags are required"),
@ -118,10 +109,8 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Shows whether system tags are required"), .help("Shows whether system tags are required"),
command!(require_tag_short, Toggle => "server_config_require_system_tag_set") command!(require_tag_short, Toggle => "server_config_require_system_tag_set")
.help("Requires or unrequires system tags for proxied messages"), .help("Requires or unrequires system tags for proxied messages"),
] ];
.into_iter();
// Suppress notifications commands
let suppress_cmds = [ let suppress_cmds = [
command!(suppress => "server_config_suppress_notifications_show") command!(suppress => "server_config_suppress_notifications_show")
.help("Shows whether notifications are suppressed for proxied messages"), .help("Shows whether notifications are suppressed for proxied messages"),
@ -131,13 +120,12 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Shows whether notifications are suppressed for proxied messages"), .help("Shows whether notifications are suppressed for proxied messages"),
command!(suppress_short, Toggle => "server_config_suppress_notifications_set") command!(suppress_short, Toggle => "server_config_suppress_notifications_set")
.help("Enables or disables notification suppression for proxied messages"), .help("Enables or disables notification suppression for proxied messages"),
] ];
.into_iter();
// Main config overview let main_cmd = once(
let main_cmd = [command!(server_config => "server_config_show") command!(server_config => "server_config_show")
.help("Shows the current server configuration")] .help("Shows the current server configuration"),
.into_iter(); );
main_cmd main_cmd
.chain(log_channel_cmds) .chain(log_channel_cmds)

View file

@ -1,6 +1,6 @@
use super::*; use super::*;
pub fn cmds() -> impl Iterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
let switch = ("switch", ["sw"]); let switch = ("switch", ["sw"]);
let edit = ("edit", ["e", "replace"]); let edit = ("edit", ["e", "replace"]);
@ -26,5 +26,4 @@ pub fn cmds() -> impl Iterator<Item = Command> {
command!(switch, copy, Optional(MemberRefs) => "switch_copy").flags(edit_flags), command!(switch, copy, Optional(MemberRefs) => "switch_copy").flags(edit_flags),
command!(switch, MemberRefs => "switch_do"), command!(switch, MemberRefs => "switch_do"),
] ]
.into_iter()
} }

View file

@ -20,7 +20,6 @@ pub fn targeted() -> TokensIterator {
pub fn edit() -> impl Iterator<Item = Command> { pub fn edit() -> impl Iterator<Item = Command> {
let system = system(); let system = system();
let system_target = targeted();
let system_new_cmd = let system_new_cmd =
once( once(
@ -36,8 +35,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's webhook URL"), .help("Clears your system's webhook URL"),
command!(system_webhook, ("url", OpaqueString) => "system_webhook_set") command!(system_webhook, ("url", OpaqueString) => "system_webhook_set")
.help("Sets your system's webhook URL"), .help("Sets your system's webhook URL"),
] ];
.into_iter();
let add_info_flags = |cmd: Command| { let add_info_flags = |cmd: Command| {
cmd.flag(("public", ["pub"])) cmd.flag(("public", ["pub"]))
@ -65,8 +63,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's name"), .help("Clears your system's name"),
command!(system_name_self, Remainder(("name", OpaqueString)) => "system_rename") command!(system_name_self, Remainder(("name", OpaqueString)) => "system_rename")
.help("Renames your system"), .help("Renames your system"),
] ];
.into_iter();
let server_name = ("servername", ["sn", "guildname"]); let server_name = ("servername", ["sn", "guildname"]);
let system_server_name_cmd = once( let system_server_name_cmd = once(
@ -80,8 +77,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's server name"), .help("Clears your system's server name"),
command!(system_server_name_self, Remainder(("name", OpaqueString)) => "system_rename_server_name") command!(system_server_name_self, Remainder(("name", OpaqueString)) => "system_rename_server_name")
.help("Renames your system's server name"), .help("Renames your system's server name"),
] ];
.into_iter();
let description = ("description", ["desc", "d"]); let description = ("description", ["desc", "d"]);
let system_description_cmd = once( let system_description_cmd = once(
@ -95,8 +91,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's description"), .help("Clears your system's description"),
command!(system_description_self, Remainder(("description", OpaqueString)) => "system_change_description") command!(system_description_self, Remainder(("description", OpaqueString)) => "system_change_description")
.help("Changes your system's description"), .help("Changes your system's description"),
] ];
.into_iter();
let color = ("color", ["colour"]); let color = ("color", ["colour"]);
let system_color_cmd = once( let system_color_cmd = once(
@ -110,8 +105,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's color"), .help("Clears your system's color"),
command!(system_color_self, ("color", OpaqueString) => "system_change_color") command!(system_color_self, ("color", OpaqueString) => "system_change_color")
.help("Changes your system's color"), .help("Changes your system's color"),
] ];
.into_iter();
let tag = ("tag", ["suffix"]); let tag = ("tag", ["suffix"]);
let system_tag_cmd = once( let system_tag_cmd = once(
@ -125,8 +119,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's tag"), .help("Clears your system's tag"),
command!(system_tag_self, Remainder(("tag", OpaqueString)) => "system_change_tag") command!(system_tag_self, Remainder(("tag", OpaqueString)) => "system_change_tag")
.help("Changes your system's tag"), .help("Changes your system's tag"),
] ];
.into_iter();
let servertag = ("servertag", ["st", "guildtag"]); let servertag = ("servertag", ["st", "guildtag"]);
let system_server_tag_cmd = once( let system_server_tag_cmd = once(
@ -140,8 +133,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's server tag"), .help("Clears your system's server tag"),
command!(system_server_tag_self, Remainder(("tag", OpaqueString)) => "system_change_server_tag") command!(system_server_tag_self, Remainder(("tag", OpaqueString)) => "system_change_server_tag")
.help("Changes your system's server tag"), .help("Changes your system's server tag"),
] ];
.into_iter();
let pronouns = ("pronouns", ["prns"]); let pronouns = ("pronouns", ["prns"]);
let system_pronouns_cmd = once( let system_pronouns_cmd = once(
@ -155,8 +147,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's pronouns"), .help("Clears your system's pronouns"),
command!(system_pronouns_self, Remainder(("pronouns", OpaqueString)) => "system_change_pronouns") command!(system_pronouns_self, Remainder(("pronouns", OpaqueString)) => "system_change_pronouns")
.help("Changes your system's pronouns"), .help("Changes your system's pronouns"),
] ];
.into_iter();
let avatar = ("avatar", ["pfp"]); let avatar = ("avatar", ["pfp"]);
let system_avatar_cmd = once( let system_avatar_cmd = once(
@ -170,11 +161,9 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's avatar"), .help("Clears your system's avatar"),
command!(system_avatar_self, ("avatar", Avatar) => "system_change_avatar") command!(system_avatar_self, ("avatar", Avatar) => "system_change_avatar")
.help("Changes your system's avatar"), .help("Changes your system's avatar"),
] ];
.into_iter();
let serveravatar = ("serveravatar", ["spfp"]); let serveravatar = ("serveravatar", ["spfp"]);
let system_server_avatar = tokens!(system_target, serveravatar);
let system_server_avatar_cmd = once( let system_server_avatar_cmd = once(
command!(system, Optional(SystemRef), serveravatar => "system_show_server_avatar") command!(system, Optional(SystemRef), serveravatar => "system_show_server_avatar")
.help("Shows the system's server avatar"), .help("Shows the system's server avatar"),
@ -186,8 +175,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's server avatar"), .help("Clears your system's server avatar"),
command!(system_server_avatar_self, ("avatar", Avatar) => "system_change_server_avatar") command!(system_server_avatar_self, ("avatar", Avatar) => "system_change_server_avatar")
.help("Changes your system's server avatar"), .help("Changes your system's server avatar"),
] ];
.into_iter();
let banner = ("banner", ["cover"]); let banner = ("banner", ["cover"]);
let system_banner_cmd = once( let system_banner_cmd = once(
@ -201,8 +189,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Clears your system's banner"), .help("Clears your system's banner"),
command!(system_banner_self, ("banner", Avatar) => "system_change_banner") command!(system_banner_self, ("banner", Avatar) => "system_change_banner")
.help("Changes your system's banner"), .help("Changes your system's banner"),
] ];
.into_iter();
let system_proxy = tokens!(system, "proxy"); let system_proxy = tokens!(system, "proxy");
let system_proxy_cmd = [ let system_proxy_cmd = [
@ -214,8 +201,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Shows your system's proxy setting for a guild"), .help("Shows your system's proxy setting for a guild"),
command!(system_proxy, GuildRef, Toggle => "system_toggle_proxy") command!(system_proxy, GuildRef, Toggle => "system_toggle_proxy")
.help("Toggle your system's proxy for a guild"), .help("Toggle your system's proxy for a guild"),
] ];
.into_iter();
let system_privacy = tokens!(system, ("privacy", ["priv"])); let system_privacy = tokens!(system, ("privacy", ["priv"]));
let system_privacy_cmd = [ let system_privacy_cmd = [
@ -225,7 +211,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
.help("Changes all privacy settings for your system"), .help("Changes all privacy settings for your system"),
command!(system_privacy, ("privacy", SystemPrivacyTarget), ("level", PrivacyLevel) => "system_change_privacy") command!(system_privacy, ("privacy", SystemPrivacyTarget), ("level", PrivacyLevel) => "system_change_privacy")
.help("Changes a specific privacy setting for your system"), .help("Changes a specific privacy setting for your system"),
].into_iter(); ];
let front = ("front", ["fronter", "fronters", "f"]); let front = ("front", ["fronter", "fronters", "f"]);
let make_front_history = |subcmd: TokensIterator| { let make_front_history = |subcmd: TokensIterator| {
@ -243,8 +229,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
make_front_history(tokens!(("fronthistory", ["fh"]))), make_front_history(tokens!(("fronthistory", ["fh"]))),
make_front_percent(tokens!(front, ("percent", ["p", "%"]))), make_front_percent(tokens!(front, ("percent", ["p", "%"]))),
make_front_percent(tokens!(("frontpercent", ["fp"]))), make_front_percent(tokens!(("frontpercent", ["fp"]))),
] ];
.into_iter();
let search_param = Optional(Remainder(("query", OpaqueString))); let search_param = Optional(Remainder(("query", OpaqueString)));
let apply_list_opts = |cmd: Command| cmd.flags(get_list_flags()); let apply_list_opts = |cmd: Command| cmd.flags(get_list_flags());
@ -270,8 +255,7 @@ pub fn edit() -> impl Iterator<Item = Command> {
let system_link = [ let system_link = [
command!("link", ("account", UserRef) => "system_link"), command!("link", ("account", UserRef) => "system_link"),
command!("unlink", ("account", OpaqueString) => "system_unlink").flag(YES), command!("unlink", ("account", OpaqueString) => "system_unlink").flag(YES),
] ];
.into_iter();
system_new_cmd system_new_cmd
.chain(system_webhook_cmd) .chain(system_webhook_cmd)

View file

@ -1,6 +1,6 @@
use ordermap::OrderMap; use ordermap::OrderMap;
use crate::{command::Command, parameter::Skip, token::Token}; use crate::{command::Command, token::Token};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct TreeBranch { pub struct TreeBranch {