From eb41fede91d072693b279f908976d2ebc2ba1ca3 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Sun, 16 Jan 2022 00:02:56 -0500 Subject: format --- src/main.rs | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 021886f..4698fb1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ -use std::{time::Duration, sync::Mutex}; +use std::{sync::Mutex, time::Duration}; use dotenv::dotenv; -use sqlx::{PgPool, postgres::PgPoolOptions}; +use sqlx::{postgres::PgPoolOptions, PgPool}; type Error = Box; type Context<'a> = poise::Context<'a, Data, Error>; @@ -11,24 +11,30 @@ mod handler; mod models; pub struct Data { - pg: Mutex, + pg: Mutex, } /// Show help menu #[poise::command(prefix_command, slash_command)] -async fn help(ctx: Context<'_>, - #[description = "Command to get help for"] command: Option, - ) -> Result<(), Error> { - poise::builtins::help(ctx, command.as_deref(), poise::builtins::HelpConfiguration::default()).await?; +async fn help( + ctx: Context<'_>, + #[description = "Command to get help for"] command: Option, +) -> Result<(), Error> { + poise::builtins::help( + ctx, + command.as_deref(), + poise::builtins::HelpConfiguration::default(), + ) + .await?; Ok(()) } async fn on_error(error: poise::FrameworkError<'_, Data, Error>) { match error { poise::FrameworkError::Setup { error } => panic!("Failed to start bot: {:?}", error), - poise::FrameworkError::Command {error, ctx} => { + poise::FrameworkError::Command { error, ctx } => { println!("Error in command {}: {:?}", ctx.command().name, error); - }, + } error => { if let Err(e) = poise::builtins::on_error(error).await { println!("Error handling error: {}", e); @@ -57,20 +63,14 @@ async fn main() { commands::meta::ping(), commands::meta::about(), commands::meta::userinfo(), - commands::actions::boop(), commands::actions::hug(), - commands::pony::randpony(), commands::pony::tpony(), - commands::osu::osup(), commands::osu::osubm(), - poise::Command { - subcommands: vec![ - commands::reactionroles::init(), - ], + subcommands: vec![commands::reactionroles::init()], ..commands::reactionroles::rroles() }, ], @@ -92,7 +92,7 @@ async fn main() { additional_prefixes: vec![ poise::Prefix::Literal("hey glitch"), poise::Prefix::Literal("hey glitch,"), - ], + ], ..Default::default() }, listener: |ctx, event, _, data| Box::pin(handler::event_handler(ctx, event, data)), @@ -105,11 +105,14 @@ async fn main() { Box::pin(async move { let pool = PgPoolOptions::new() .max_connections(5) - .connect(&std::env::var("DATABASE_URL").unwrap_or("postgres://postgres@localhost/glitch".to_string())) + .connect( + &std::env::var("DATABASE_URL") + .unwrap_or("postgres://postgres@localhost/glitch".to_string()), + ) .await .expect("Couldn't connect to postgresql"); Ok(Data { - pg: Mutex::new(pool) + pg: Mutex::new(pool), }) }) }) @@ -118,4 +121,3 @@ async fn main() { .await .unwrap(); } - -- cgit v1.2.3