From c71dbe72143e2528e20e17421d430fc76c85f16c Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Tue, 17 Sep 2024 22:26:46 +0100 Subject: [PATCH] fix: optional parms must be after required ones --- src/commands/add_server.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/commands/add_server.rs b/src/commands/add_server.rs index 9a50608..e140283 100644 --- a/src/commands/add_server.rs +++ b/src/commands/add_server.rs @@ -45,7 +45,7 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri }; let mut role_past = None; - if let Some(x) = command.data.options.get(2) { + if let Some(x) = command.data.options.get(5) { if let Some(CommandDataOptionValue::Role(role)) = &x.resolved { role_past = Some(role.id.to_owned()); } @@ -54,7 +54,7 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri let bot_channel_id = if let CommandDataOptionValue::Channel(channel) = command .data .options - .get(3) + .get(2) .expect("Expected channel option") .resolved .as_ref() @@ -68,7 +68,7 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri let server_name = if let CommandDataOptionValue::String(name) = command .data .options - .get(4) + .get(3) .expect("Expected Server Name option") .resolved .as_ref() @@ -82,7 +82,7 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri let wolves_link = if let CommandDataOptionValue::String(wolves) = command .data .options - .get(5) + .get(4) .expect("Expected Wolves Link option") .resolved .as_ref() @@ -140,13 +140,6 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio .kind(CommandOptionType::Role) .required(true) }) - .create_option(|option| { - option - .name("role_past") - .description("Role for Past members") - .kind(CommandOptionType::Role) - .required(false) - }) .create_option(|option| { option .name("bot_channel") @@ -168,6 +161,13 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio .kind(CommandOptionType::String) .required(true) }) + .create_option(|option| { + option + .name("role_past") + .description("Role for Past members") + .kind(CommandOptionType::Role) + .required(false) + }) } async fn add_server(db: &Pool, ctx: &Context, server: &Servers) -> Result, Error> {