mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(commands): allow commands to not be suggested
This commit is contained in:
parent
f0d287b873
commit
58f07c3baa
3 changed files with 14 additions and 6 deletions
|
|
@ -33,6 +33,7 @@ pub struct Command {
|
|||
pub tokens: Vec<Token>,
|
||||
pub help: SmolStr,
|
||||
pub cb: SmolStr,
|
||||
pub show_in_suggestions: bool,
|
||||
}
|
||||
|
||||
impl Command {
|
||||
|
|
@ -40,11 +41,13 @@ impl Command {
|
|||
tokens: impl IntoIterator<Item = Token>,
|
||||
help: impl Into<SmolStr>,
|
||||
cb: impl Into<SmolStr>,
|
||||
show_in_suggestions: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
tokens: tokens.into_iter().collect(),
|
||||
help: help.into(),
|
||||
cb: cb.into(),
|
||||
show_in_suggestions,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,8 +66,11 @@ impl Display for Command {
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! command {
|
||||
([$($v:expr),+], $cb:expr, $help:expr, suggest = $suggest:expr) => {
|
||||
$crate::commands::Command::new([$($v.to_token()),*], $help, $cb, $suggest)
|
||||
};
|
||||
([$($v:expr),+], $cb:expr, $help:expr) => {
|
||||
$crate::commands::Command::new([$($v.to_token()),*], $help, $cb)
|
||||
$crate::command!([$($v),+], $cb, $help, suggest = true)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,6 @@ pub fn cmds() -> impl Iterator<Item = Command> {
|
|||
"member_show",
|
||||
"Shows information about a member"
|
||||
),
|
||||
command!(
|
||||
[member, MemberRef("target"), "soulscream"],
|
||||
"member_soulscream",
|
||||
"todo"
|
||||
),
|
||||
command!(
|
||||
[member, MemberRef("target"), description],
|
||||
"member_desc_show",
|
||||
|
|
@ -55,6 +50,12 @@ pub fn cmds() -> impl Iterator<Item = Command> {
|
|||
"member_privacy_update",
|
||||
"Changes a member's privacy settings"
|
||||
),
|
||||
command!(
|
||||
[member, MemberRef("target"), "soulscream"],
|
||||
"member_soulscream",
|
||||
"todo",
|
||||
suggest = false
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ pub fn parse_command(prefix: String, input: String) -> CommandResult {
|
|||
if !possible_commands.is_empty() {
|
||||
error.push_str(" Perhaps you meant to use one of the commands below:\n");
|
||||
for command in possible_commands {
|
||||
if !command.show_in_suggestions { continue }
|
||||
writeln!(&mut error, "- **{prefix}{command}** - *{}*", command.help)
|
||||
.expect("oom");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue