From 5ea60282f38fd5839406f64d992e771a4bc6a6d2 Mon Sep 17 00:00:00 2001 From: Max Bossing Date: Wed, 6 Aug 2025 17:31:46 +0200 Subject: [PATCH] refactor: clean up main --- src/main.rs | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2ced1d7..6f1a425 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,15 +44,10 @@ async fn main() { let config: Config = toml::de::from_str(&config_file_contents).expect("failed to deserialize config file"); - println!("{config:?}"); - let options = poise::FrameworkOptions { commands: vec![commands::ping::ping(), commands::sandwich::sandwich_list()], prefix_options: poise::PrefixFrameworkOptions { prefix: Some("!".into()), - edit_tracker: Some(Arc::new(poise::EditTracker::for_timespan( - Duration::from_secs(3600), - ))), additional_prefixes: vec![ poise::Prefix::Literal("sandwichmeister,"), poise::Prefix::Literal("sandwichmeister"), @@ -61,32 +56,6 @@ async fn main() { ], ..Default::default() }, - // The global error handler for all error cases that may occur - on_error: |error| Box::pin(on_error(error)), - // This code is run before every command - pre_command: |ctx| { - Box::pin(async move { - println!("Executing command {}...", ctx.command().qualified_name); - }) - }, - // This code is run after a command if it was successful (returned Ok) - post_command: |ctx| { - Box::pin(async move { - println!("Executed command {}!", ctx.command().qualified_name); - }) - }, - // Every command invocation must pass this check to continue execution - // command_check: Some(|ctx| { - // Box::pin(async move { - // if ctx.author().id == 123456789 { - // return Ok(false); - // } - // Ok(true) - // }) - // }), - // Enforce command checks even for owners (enforced by default) - // Set to true to bypass checks, which is useful for testing - skip_checks_for_owners: false, event_handler: |_ctx, event, _framework, _data| { Box::pin(async move { println!( @@ -103,8 +72,11 @@ async fn main() { .setup(move |ctx, _ready, framework| { Box::pin(async move { println!("Logged in as {}", _ready.user.name); + poise::builtins::register_globally(ctx, &framework.options().commands).await?; + let directus = DirectusClient::new(config.directus); + let sandwiches = directus .get_sandwiches() .await