about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs36
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),