From a9006f1068060ec9e78af55fe8e59ffcea1664d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Czy=C5=BC?= Date: Tue, 30 Jan 2024 15:43:59 +0100 Subject: [PATCH] tools and kashi init --- src/commands/kashi/kashi.rs | 10 ++++++++++ src/commands/kashi/mod.rs | 1 + src/commands/mod.rs | 4 +++- src/commands/music/play.rs | 0 src/commands/tools/mod.rs | 1 + src/commands/tools/ping.rs | 17 +++++++++++++++++ src/main.rs | 13 ++++++++++++- 7 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/commands/kashi/kashi.rs create mode 100644 src/commands/kashi/mod.rs create mode 100644 src/commands/music/play.rs create mode 100644 src/commands/tools/mod.rs create mode 100644 src/commands/tools/ping.rs diff --git a/src/commands/kashi/kashi.rs b/src/commands/kashi/kashi.rs new file mode 100644 index 0000000..746bffb --- /dev/null +++ b/src/commands/kashi/kashi.rs @@ -0,0 +1,10 @@ +use serenity::{all::Message, client::Context, framework::standard::{macros::command, CommandResult}}; + +use crate::commands::misc::check_msg; + +#[command] +async fn kashi(ctx: &Context, msg: &Message) -> CommandResult { + check_msg(msg.reply(ctx, "Kashi lyrics platform integration").await); + + Ok(()) +} \ No newline at end of file diff --git a/src/commands/kashi/mod.rs b/src/commands/kashi/mod.rs new file mode 100644 index 0000000..b52d95f --- /dev/null +++ b/src/commands/kashi/mod.rs @@ -0,0 +1 @@ +pub mod kashi; \ No newline at end of file diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 749386f..c60b84c 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,2 +1,4 @@ +pub mod kashi; +pub mod misc; pub mod music; -pub mod misc; \ No newline at end of file +pub mod tools; diff --git a/src/commands/music/play.rs b/src/commands/music/play.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/commands/tools/mod.rs b/src/commands/tools/mod.rs new file mode 100644 index 0000000..924dabf --- /dev/null +++ b/src/commands/tools/mod.rs @@ -0,0 +1 @@ +pub mod ping; \ No newline at end of file diff --git a/src/commands/tools/ping.rs b/src/commands/tools/ping.rs new file mode 100644 index 0000000..b378806 --- /dev/null +++ b/src/commands/tools/ping.rs @@ -0,0 +1,17 @@ +use std::time::SystemTime; + +use serenity::{all::Message, client::Context, framework::standard::{macros::command, CommandResult}}; + +use crate::commands::misc::check_msg; + +#[command] +async fn ping(ctx: &Context, msg: &Message) -> CommandResult { + let system_now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_millis() as i64; + let message_now = msg.timestamp.timestamp_millis(); + + // println!("System Time: {} ||| Message Time: {}", system_now, message_now); + + check_msg(msg.reply(ctx, format!("Pong! (latency: {} ms)", system_now - message_now)).await); + + Ok(()) +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 68bc09b..95f7df4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,11 +17,18 @@ use serenity::{ mod commands; +// music management commands use crate::commands::music::deafen::*; use crate::commands::music::join::*; use crate::commands::music::leave::*; use crate::commands::music::mute::*; +// tools +use crate::commands::tools::ping::*; + +// kashi +use crate::commands::kashi::kashi::*; + struct HttpKey; impl TypeMapKey for HttpKey { @@ -38,7 +45,11 @@ impl EventHandler for Handler { } #[group] -#[commands(join, deafen, leave, mute)] +#[commands( + join, deafen, leave, mute, + ping, + kashi +)] struct General; #[tokio::main]