diff options
author | gennyble <gen@nyble.dev> | 2025-04-19 12:52:30 -0500 |
---|---|---|
committer | gennyble <gen@nyble.dev> | 2025-04-19 12:52:30 -0500 |
commit | 170fb54426ea157c775cc5a178cf018bcafb15f1 (patch) | |
tree | bb73b0536e27a87ba195b68a47109a807da3e35f | |
parent | c82ab046c89cf917226a4232dfe183c66aa06d16 (diff) | |
download | leaberblord-170fb54426ea157c775cc5a178cf018bcafb15f1.tar.gz leaberblord-170fb54426ea157c775cc5a178cf018bcafb15f1.zip |
move DM gate somewhere it actually works
-rw-r--r-- | src/main.rs | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs index 494b3dd..ca26408 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,7 +60,7 @@ macro_rules! success { #[tokio::main] async fn main() -> anyhow::Result<()> { - dotenv::dotenv()?; + dotenv::dotenv().ok(); let conf = Confindent::from_file("/etc/leaberblord.conf").unwrap(); let db_dir = conf @@ -96,7 +96,7 @@ async fn main() -> anyhow::Result<()> { for cmd in cmd_ap_global { println!( - "global commeand- [{}] {}: {}", + "global command- [{}] {}: {}", cmd.id .map(|c| c.get().to_string()) .unwrap_or("-".to_owned()), @@ -126,6 +126,22 @@ async fn handle_event( ) -> Result<(), Box<dyn Error + Send + Sync>> { match event { Event::InteractionCreate(create) => { + // Don't allow direct message commanding + if create.is_dm() { + let iclient = http.interaction(Id::new(APP_ID)); + iclient + .create_response( + create.id, + &create.token, + &InteractionResponse { + kind: InteractionResponseType::ChannelMessageWithSource, + data: Some(fail!("leaderboards not supported in DMs")), + }, + ) + .await + .unwrap(); + } + let data = create.data.as_ref().unwrap(); if let InteractionData::ApplicationCommand(cmd) = data { @@ -193,22 +209,6 @@ async fn command_handler( command: Commands, command_data: &CommandData, ) { - // Don't allow direct message commanding - if create.is_dm() { - let iclient = http.interaction(Id::new(APP_ID)); - iclient - .create_response( - create.id, - &create.token, - &InteractionResponse { - kind: InteractionResponseType::ChannelMessageWithSource, - data: Some(fail!("leaderboards not supported in DMs")), - }, - ) - .await - .unwrap(); - } - // Handle the command and create our interaction response data let data = match command { Commands::Leaderboard => get_leaderboard(&db, guild), |