assistant: Put /docs and /project behind a setting (#16186)

This PR puts the availability of the `/docs` and `/project` slash
commands behind their respective settings.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-08-13 17:32:24 -04:00 committed by GitHub
parent c3edbd7d9a
commit 47628515e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 91 additions and 16 deletions

View file

@ -56,6 +56,14 @@ impl SlashCommandRegistry {
state.commands.insert(command_name, Arc::new(command));
}
/// Unregisters the provided [`SlashCommand`].
pub fn unregister_command(&self, command: impl SlashCommand) {
let mut state = self.state.write();
let command_name: Arc<str> = command.name().into();
state.featured_commands.remove(&command_name);
state.commands.remove(&command_name);
}
/// Returns the names of registered [`SlashCommand`]s.
pub fn command_names(&self) -> Vec<Arc<str>> {
self.state.read().commands.keys().cloned().collect()