diff options
author | Cara Salter <cara@devcara.com> | 2022-05-13 10:50:42 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-05-13 10:50:42 -0400 |
commit | dc1039fa1e4ca4fe55e9ab2123260aa1a2006503 (patch) | |
tree | 0328a9950b2f87280acba4662ac2de3bc63b676e /src/main.rs | |
parent | 5999e6a803a7b848acf054918fec9ee5024d5697 (diff) | |
download | glitch-ng-dc1039fa1e4ca4fe55e9ab2123260aa1a2006503.tar.gz glitch-ng-dc1039fa1e4ca4fe55e9ab2123260aa1a2006503.zip |
filter: Fully flesh out deletion/review handler
WIP: Currently, deletions do not work. Error returned:
User event listener encountered an error on InteractionCreate
event: The bot is not author of this message.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index 38a849b..de322ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,12 +5,16 @@ * This iteration will focus on code correctness and durability. The major goal is to avoid what * happened to the Campmaster by avoiding code rot and forcing documentation on _everything_ */ +#[macro_use] +extern crate tracing; use std::{sync::Mutex, time::Duration}; use dotenv::dotenv; use sqlx::{postgres::PgPoolOptions, PgPool}; use tracing::{info, instrument}; +use poise::serenity_prelude as serenity; + type Error = Box<dyn std::error::Error + Send + Sync>; type Context<'a> = poise::Context<'a, Data, Error>; @@ -43,14 +47,14 @@ 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 } => { - println!("Error in command {}: {:?}", ctx.command().name, error); - ctx.say(format!("Whoops! Something went wrong: {:?}", error)) + error!("Error in command {}: {:?}", ctx.command().name, error); + ctx.say(format!("Whoops! Something went wrong: `{:?}`", error)) .await .unwrap(); } error => { if let Err(e) = poise::builtins::on_error(error).await { - println!("Error handling error: {}", e); + error!("Error handling error: {}", e); } } } @@ -81,11 +85,7 @@ 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::pony::ponybyid(), + commands::actions::boop(), commands::actions::hug(), commands::pony::randpony(), commands::pony::tpony(), commands::pony::ponybyid(), commands::osu::osup(), commands::osu::osubm(), poise::Command { @@ -100,6 +100,8 @@ async fn main() { subcommands: vec![ commands::filters::list(), commands::filters::add(), + commands::filters::del(), + commands::filters::channel(), ], ..commands::filters::filter() }, @@ -109,12 +111,12 @@ async fn main() { // Honestly could probably be removed, but it's kept in for ~reasons~ pre_command: |ctx| { Box::pin(async move { - println!("Executing command {}...", ctx.command().name); + debug!("Executing command {}...", ctx.command().name); }) }, post_command: |ctx| { Box::pin(async move { - println!("Done executing command {}!", ctx.command().name); + debug!("Done executing command {}!", ctx.command().name); }) }, @@ -136,6 +138,9 @@ async fn main() { poise::Framework::build() .token(std::env::var("DISCORD_TOKEN").unwrap_or("BAD-TOKEN".into())) + .client_settings(|c| { + c.intents(serenity::GatewayIntents::all()) + }) .user_data_setup(move |_ctx, _ready, _framework| { Box::pin(async move { /* |