Geoffrey-rs/geoffrey_bot/src/commands/mod.rs

29 lines
1.1 KiB
Rust

pub mod add_item;
pub mod add_location;
pub mod bot_command;
pub mod find;
pub mod selling;
use crate::commands::add_item::AddItemCommand;
use crate::commands::add_location::AddLocationCommand;
use crate::commands::bot_command::{BotCommand, CommandError};
use crate::commands::find::FindCommand;
use crate::commands::selling::SellingCommand;
use serenity::model::interactions::application_command::ApplicationCommand;
use serenity::prelude::*;
pub async fn create_commands(ctx: &Context) -> Result<Vec<ApplicationCommand>, CommandError> {
let mut commands: Vec<ApplicationCommand> = Vec::new();
for command in ApplicationCommand::get_global_application_commands(&ctx.http).await? {
ApplicationCommand::delete_global_application_command(&ctx.http, command.id).await?;
}
commands.push(FindCommand::create_app_command(ctx).await?);
commands.push(SellingCommand::create_app_command(ctx).await?);
commands.push(AddLocationCommand::create_app_command(ctx).await?);
commands.push(AddItemCommand::create_app_command(ctx).await?);
Ok(commands)
}