From 1b6eb2e5ef4eab269235aa833b7347afd13c3613 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 5 Dec 2023 08:55:37 -0500 Subject: fix: make config command a prefix command --- src/commands/moderation/config.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/commands') diff --git a/src/commands/moderation/config.rs b/src/commands/moderation/config.rs index a8af8a0..b2b0ab4 100644 --- a/src/commands/moderation/config.rs +++ b/src/commands/moderation/config.rs @@ -8,11 +8,13 @@ use color_eyre::eyre::{eyre, Result}; use log::*; use poise::serenity_prelude::{GuildChannel, ReactionType}; -fn split_list(list: String) -> Vec +fn split_argument(list: String) -> Vec where T: FromStr, { - list.split(',').filter_map(|s| s.parse().ok()).collect() + list.split(',') + .filter_map(|s| s.trim().parse().ok()) + .collect() } fn prop_to_val(setting: &SettingsProperties, settings: &Settings) -> String { @@ -35,6 +37,7 @@ fn prop_to_val(setting: &SettingsProperties, settings: &Settings) -> String { #[poise::command( slash_command, + prefix_command, subcommands("set", "get"), default_member_permissions = "MANAGE_GUILD" )] @@ -43,7 +46,7 @@ pub async fn config(_ctx: Context<'_>) -> Result<()> { } #[allow(clippy::too_many_arguments)] -#[poise::command(slash_command, ephemeral, guild_only)] +#[poise::command(slash_command, prefix_command, ephemeral, guild_only)] pub async fn set( ctx: Context<'_>, #[channel_types("Text")] @@ -74,7 +77,7 @@ pub async fn set( } if let Some(watch) = pinboard_watch { - let channels = split_list(watch); + let channels = split_argument(watch); debug!("Setting pinboard_watch to {channels:#?} for {gid}"); settings.pinboard_watch = Some(channels); @@ -126,7 +129,7 @@ pub async fn set( Ok(()) } -#[poise::command(slash_command, ephemeral, guild_only)] +#[poise::command(slash_command, prefix_command, ephemeral, guild_only)] pub async fn get( ctx: Context<'_>, #[description = "The setting you want to get"] setting: SettingsProperties, -- cgit v1.2.3