html terminal
Diffstat (limited to 'src/bot/config.rs')
| -rw-r--r-- | src/bot/config.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/bot/config.rs b/src/bot/config.rs new file mode 100644 index 0000000..a68a905 --- /dev/null +++ b/src/bot/config.rs @@ -0,0 +1,55 @@ +use super::{Context, Result}; +use crate::{return_next, send_ctx}; +use convert_case::{Case, Casing}; +use futures_util::StreamExt; + +const ITEMS: &'static [&'static str] = &[ + "autoUpdate", + "showConnectMessages", + "enableVotekick", + "startCommands", + "logging", + "strict", + "antiSpam", + "interactRateWindow", + "interactRateKick", + "messageRateLimit", + "messageSpamKick", + "packetSpamLimit", + "chatSpamLimit", + "socketInput", + "socketInputPort", + "socketInputAddress", + "allowCustomClients", + "whitelist", + "motd", + "autosave", + "autosaveAmount", + "debug", + "snapshotInterval", + "autoPause", +]; + +async fn complete<'a>( + _ctx: Context<'_>, + partial: &'a str, +) -> impl futures::Stream<Item = String> + 'a { + futures::stream::iter(ITEMS) + .filter(move |name| futures::future::ready(name.starts_with(partial))) + .map(|name| name.from_case(Case::Camel).to_case(Case::Lower)) +} + +#[poise::command(slash_command, category = "Configuration", rename = "config")] +/// change a setting +pub async fn set( + ctx: Context<'_>, + #[autocomplete = "complete"] + #[description = "setting to change"] + setting: String, + #[description = "the value"] config: String, +) -> Result<()> { + let setting = setting.from_case(Case::Lower).to_case(Case::Camel); + send_ctx!(ctx, "config {setting} {config}")?; + return_next!(ctx) +} +// TODO: config::list |