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 skynet_discord_bot::{get_now_iso, random_string, Config, DataBase, Wolves, WolvesVerify};
use sqlx::{Pool, Sqlite}; use sqlx::{Pool, Sqlite};
pub(crate) mod link {
use super::*;
pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String { pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String {
let db_lock = { let db_lock = {
let data_read = ctx.data.read().await; 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) .fetch_optional(db)
.await .await
} }
}

View file

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