Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,20 @@
"Fix": {
"permission": "Mod",
"userPermissions": ["715209"],
"alias": ["f"]
"alias": ["f"],
"disabled": false
},
"Switch": {
"permission": "Mod",
"userPermissions": null,
"alias": ["ss"]
"alias": ["ss"],
"disabled": false
},
"Bitrate": {
"permission": null,
"userPermissions": null,
"alias": ["b"]
"alias": ["b"],
"disabled": false
}
}
},
Expand Down
19 changes: 19 additions & 0 deletions src/chat/chat_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,25 @@ impl ChatHandler {
) -> Option<bool> {
let state = user.state.read().await;
let chat = state.config.chat.as_ref()?;
let prefix = &chat.prefix;
// grab the raw command token (e.g. "!switch" → "switch")
let raw = msg.message.split_whitespace().next().unwrap_or("");
if let Some(cmd_str) = raw.strip_prefix(prefix) {
let cmd = super::Command::from(cmd_str);
let disabled_in_user = chat
.commands
.as_ref()
.and_then(|m| m.get(&cmd))
.map_or(false, |info| info.disabled);
let disabled_in_default = self
.default_commands
.get(&cmd)
.map_or(false, |info| info.disabled);
if disabled_in_user || disabled_in_default {
debug!("Command {:?} is disabled, skipping execution", cmd);
return Some(false);
}
}

let chat::CommandPermissions {
permission,
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ pub struct CommandInfo {
pub permission: Option<chat::Permission>,
pub user_permissions: Option<Vec<String>>,
pub alias: Option<Vec<String>>,
pub disabled: bool,
}

pub struct File {
Expand Down