1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add hidden command support

This commit is contained in:
NG (Graham)
2026-01-04 17:13:31 -05:00
parent 2e0c6b2b62
commit 09c1d2b344
2 changed files with 6 additions and 1 deletions

View File

@@ -56,6 +56,7 @@ pub struct ChatCommand {
regex: regex::Regex,
op: ChatOperation,
perms: ExecutePermission,
is_hidden: bool,
}
impl ChatCommand {
@@ -64,6 +65,7 @@ impl ChatCommand {
regex: regex::RegexBuilder::new(&command.regex).build()?,
op: ChatOperation::from_persist(command.op),
perms: ExecutePermission::from_persist(command.permission),
is_hidden: command.hidden,
})
}
@@ -220,9 +222,10 @@ impl BuiltIn {
}
Self::Help => {
use core::fmt::Write;
let force_all = text.trim().split(' ').any(|word| word == "--all");
let force_all = text.trim().split(' ').any(|word| word == "all");
let mut msg = String::new();
for command in ctx.chat_system.chat_config().commands.iter() {
if command.is_hidden { continue; }
if command.perms.has_perms(ctx.user) || force_all {
let raw_re = command.regex.to_string();
let pretty_name = Self::prettify_re(&raw_re);

View File

@@ -55,6 +55,8 @@ pub struct ChatCommand {
pub regex: String,
pub op: ChatOperation,
pub permission: ChatPermission,
#[serde(default)]
pub hidden: bool,
}
impl super::config::SelfValidator for ChatCommand {