From 7d26f636d50892c69e5df6fd68cc75e94969f046 Mon Sep 17 00:00:00 2001 From: xy Date: Fri, 23 Feb 2024 01:44:46 +0900 Subject: [PATCH] Adjust bot module visibility and decrease interval duration The bot module within the 'discord' directory is now private, but its Handler is publicly accessible. This restructuring improves encapsulation and keeps implementation detail away from the public interface. Additionally, the bot's processing loop interval has been reduced from 1200 to 900 milliseconds, potentially increasing response time. --- src/bin/bootstrap.rs | 2 +- src/discord/bot.rs | 2 +- src/discord/mod.rs | 3 ++- src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bin/bootstrap.rs b/src/bin/bootstrap.rs index 1805ec4..22186a9 100644 --- a/src/bin/bootstrap.rs +++ b/src/bin/bootstrap.rs @@ -5,7 +5,7 @@ use tokio; use dotenv; -use gpt_discord_bot::bot::Handler; +use gpt_discord_bot::Handler; #[tokio::main] async fn main() { diff --git a/src/discord/bot.rs b/src/discord/bot.rs index 40048b7..5fdaaa6 100644 --- a/src/discord/bot.rs +++ b/src/discord/bot.rs @@ -56,7 +56,7 @@ impl EventHandler for Handler { }; let mut result = String::new(); - let mut interval = interval(Duration::from_millis(1200)); + let mut interval = interval(Duration::from_millis(900)); loop { select! { diff --git a/src/discord/mod.rs b/src/discord/mod.rs index 1cbfd96..5db2c25 100644 --- a/src/discord/mod.rs +++ b/src/discord/mod.rs @@ -1 +1,2 @@ -pub mod bot; +mod bot; +pub use bot::Handler; diff --git a/src/lib.rs b/src/lib.rs index 520057c..61cc588 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,2 @@ mod discord; -pub use crate::discord::bot; +pub use crate::discord::Handler;