From e62dfcc4c89fdcdf190b8f214bae7a7f905818f2 Mon Sep 17 00:00:00 2001 From: minneelyyyy Date: Fri, 21 Feb 2025 15:33:05 -0500 Subject: [PATCH] use #[rest] on many string arguments --- src/commands/gambling/shop.rs | 5 +++-- src/commands/gambling/wager.rs | 1 + src/commands/mod.rs | 1 + src/commands/self_roles/color.rs | 6 +++++- src/commands/self_roles/name.rs | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/commands/gambling/shop.rs b/src/commands/gambling/shop.rs index 08df0be..ecec288 100644 --- a/src/commands/gambling/shop.rs +++ b/src/commands/gambling/shop.rs @@ -37,9 +37,10 @@ async fn autocomplete_shop<'a>( #[poise::command(slash_command, prefix_command)] pub async fn buy(ctx: Context<'_>, + count: Option, #[autocomplete = "autocomplete_shop"] - item: String, - count: Option) -> Result<(), Error> + #[rest] + item: String) -> Result<(), Error> { let count = count.unwrap_or(1); diff --git a/src/commands/gambling/wager.rs b/src/commands/gambling/wager.rs index eb77889..2234929 100644 --- a/src/commands/gambling/wager.rs +++ b/src/commands/gambling/wager.rs @@ -8,6 +8,7 @@ pub async fn wager( ctx: Context<'_>, amount: String, #[autocomplete = "super::autocomplete_inventory"] + #[rest] item: Option) -> Result<(), Error> { let mut tx = ctx.data().database.begin().await?; diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 4907154..5cc61fe 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -15,6 +15,7 @@ use crate::common::{Data, Error, Context}; #[poise::command(prefix_command, slash_command)] async fn help(ctx: Context<'_>, #[description = "Specific command to get help with"] + #[rest] command: Option) -> Result<(), Error> { poise::builtins::help(ctx, command.as_deref(), poise::builtins::HelpConfiguration::default()).await?; diff --git a/src/commands/self_roles/color.rs b/src/commands/self_roles/color.rs index c411c16..ac83f8d 100644 --- a/src/commands/self_roles/color.rs +++ b/src/commands/self_roles/color.rs @@ -61,7 +61,11 @@ async fn autocomplete_colors<'a>( /// Change the color of your personal role #[poise::command(slash_command, prefix_command)] -pub async fn color(ctx: Context<'_>, #[autocomplete = "autocomplete_colors"] color: String) -> Result<(), Error> { +pub async fn color(ctx: Context<'_>, + #[autocomplete = "autocomplete_colors"] + #[rest] + color: String) -> Result<(), Error> +{ let color = if let Some(named) = COLORS.get(color.as_str()) { named.clone() } else { diff --git a/src/commands/self_roles/name.rs b/src/commands/self_roles/name.rs index 314f901..17a5120 100644 --- a/src/commands/self_roles/name.rs +++ b/src/commands/self_roles/name.rs @@ -5,7 +5,7 @@ use poise::serenity_prelude::EditRole; /// Change the name of your personal role #[poise::command(slash_command, prefix_command)] -pub async fn name(ctx: Context<'_>, name: String) -> Result<(), Error> { +pub async fn name(ctx: Context<'_>, #[rest] name: String) -> Result<(), Error> { let guild = if let Some(guild) = ctx.guild_id() { guild } else {