Wip commit

This commit is contained in:
jude
2024-01-06 19:48:17 +00:00
parent cce0de7c75
commit e4e9af2bb4
37 changed files with 1051 additions and 1366 deletions

View File

@ -23,9 +23,12 @@ use std::{
use chrono_tz::Tz;
use log::{error, warn};
use poise::serenity_prelude::model::{
gateway::GatewayIntents,
id::{GuildId, UserId},
use poise::serenity_prelude::{
model::{
gateway::GatewayIntents,
id::{GuildId, UserId},
},
ClientBuilder,
};
use sqlx::{MySql, Pool};
use tokio::sync::{broadcast, broadcast::Sender, RwLock};
@ -36,7 +39,6 @@ use crate::{
event_handlers::listener,
hooks::all_checks,
models::command_macro::CommandMacro,
utils::register_application_commands,
};
type Database = MySql;
@ -213,11 +215,10 @@ async fn _main(tx: Sender<()>) -> Result<(), Box<dyn StdError + Send + Sync>> {
.map(|t| t.timezone.parse::<Tz>().unwrap())
.collect::<Vec<Tz>>();
poise::Framework::builder()
.token(discord_token)
let framework = poise::Framework::builder()
.setup(move |ctx, _bot, framework| {
Box::pin(async move {
register_application_commands(ctx, framework, None).await.unwrap();
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
let kill_tx = tx.clone();
let kill_recv = tx.subscribe();
@ -261,9 +262,12 @@ async fn _main(tx: Sender<()>) -> Result<(), Box<dyn StdError + Send + Sync>> {
})
})
.options(options)
.intents(GatewayIntents::GUILDS)
.run_autosharded()
.await?;
.build();
let mut client =
ClientBuilder::new(&discord_token, GatewayIntents::GUILDS).framework(framework).await?;
client.start_autosharded().await?;
Ok(())
}