summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorseth <[email protected]>2023-12-05 08:55:37 -0500
committerseth <[email protected]>2023-12-15 16:41:13 -0500
commit1b6eb2e5ef4eab269235aa833b7347afd13c3613 (patch)
treeb2459d859125cb5e5ef6a372a5119cb8b52156e3 /src/commands
parenta5a329c41e255d71ad06c0ce3c54288da0040b36 (diff)
fix: make config command a prefix command
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/moderation/config.rs13
1 files changed, 8 insertions, 5 deletions
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<T>(list: String) -> Vec<T>
+fn split_argument<T>(list: String) -> Vec<T>
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,