fmt: package it better

This commit is contained in:
silver 2023-09-17 15:35:41 +01:00
parent 14cbf0bcad
commit 98e61d7548
2 changed files with 173 additions and 177 deletions

View file

@ -15,6 +15,9 @@ use serenity::{
use skynet_discord_bot::{get_now_iso, random_string, Config, DataBase, Wolves, WolvesVerify};
use sqlx::{Pool, Sqlite};
pub(crate) mod link {
use super::*;
pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String {
let db_lock = {
let data_read = ctx.data.read().await;
@ -228,3 +231,4 @@ async fn save_to_db(db: &Pool<Sqlite>, record: &Wolves, auth: &str, user: &str)
.fetch_optional(db)
.await
}
}

View file

@ -4,10 +4,7 @@ use serenity::{
async_trait,
client::{Context, EventHandler},
model::{
application::{
command::Command,
interaction::{Interaction, InteractionResponseType},
},
application::{command::Command, interaction::Interaction},
gateway::{GatewayIntents, Ready},
guild,
},
@ -59,7 +56,7 @@ impl EventHandler for Handler {
println!("[Main] {} is connected!", ready.user.name);
Command::set_global_application_commands(&ctx.http, |commands| {
commands.create_application_command(|command| commands::link_email::register(command))
commands.create_application_command(|command| commands::link_email::link::register(command))
})
.await
.ok();
@ -71,16 +68,11 @@ impl EventHandler for Handler {
//println!("Received command interaction: {:#?}", command);
let content = match command.data.name.as_str() {
"link" => commands::link_email::run(&command, &ctx).await,
"link" => commands::link_email::link::run(&command, &ctx).await,
_ => "not implemented :(".to_string(),
};
if let Err(why) = command
.edit_original_interaction_response(&ctx.http, |response| {
response.content(content)
})
.await
{
if let Err(why) = command.edit_original_interaction_response(&ctx.http, |response| response.content(content)).await {
println!("Cannot respond to slash command: {}", why);
}
}