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;
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<Sqlite>, ctx: &Context, server: &Servers) -> Result<Option<Servers>, Error> {