fix: optional parms must be after required ones

This commit is contained in:
silver 2024-09-17 22:26:46 +01:00
parent bf08aa650c
commit c71dbe7214
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D

View file

@ -45,7 +45,7 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri
}; };
let mut role_past = None; 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 { if let Some(CommandDataOptionValue::Role(role)) = &x.resolved {
role_past = Some(role.id.to_owned()); 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 let bot_channel_id = if let CommandDataOptionValue::Channel(channel) = command
.data .data
.options .options
.get(3) .get(2)
.expect("Expected channel option") .expect("Expected channel option")
.resolved .resolved
.as_ref() .as_ref()
@ -68,7 +68,7 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri
let server_name = if let CommandDataOptionValue::String(name) = command let server_name = if let CommandDataOptionValue::String(name) = command
.data .data
.options .options
.get(4) .get(3)
.expect("Expected Server Name option") .expect("Expected Server Name option")
.resolved .resolved
.as_ref() .as_ref()
@ -82,7 +82,7 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri
let wolves_link = if let CommandDataOptionValue::String(wolves) = command let wolves_link = if let CommandDataOptionValue::String(wolves) = command
.data .data
.options .options
.get(5) .get(4)
.expect("Expected Wolves Link option") .expect("Expected Wolves Link option")
.resolved .resolved
.as_ref() .as_ref()
@ -140,13 +140,6 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio
.kind(CommandOptionType::Role) .kind(CommandOptionType::Role)
.required(true) .required(true)
}) })
.create_option(|option| {
option
.name("role_past")
.description("Role for Past members")
.kind(CommandOptionType::Role)
.required(false)
})
.create_option(|option| { .create_option(|option| {
option option
.name("bot_channel") .name("bot_channel")
@ -168,6 +161,13 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio
.kind(CommandOptionType::String) .kind(CommandOptionType::String)
.required(true) .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<Sqlite>, ctx: &Context, server: &Servers) -> Result<Option<Servers>, Error> { async fn add_server(db: &Pool<Sqlite>, ctx: &Context, server: &Servers) -> Result<Option<Servers>, Error> {