mirror of
https://github.com/eRgo35/lyra.git
synced 2026-02-04 04:16:11 +01:00
24 lines
556 B
Rust
24 lines
556 B
Rust
use crate::{Context, Error};
|
|
use std::time::SystemTime;
|
|
|
|
/// Pings you backs with a response time
|
|
#[poise::command(
|
|
prefix_command,
|
|
slash_command,
|
|
category = "Tools"
|
|
)]
|
|
pub async fn ping(
|
|
ctx: Context<'_>
|
|
) -> Result<(), Error> {
|
|
let system_now = SystemTime::now()
|
|
.duration_since(SystemTime::UNIX_EPOCH)
|
|
.unwrap().as_millis() as i64;
|
|
|
|
let message_now = ctx.created_at().timestamp_millis();
|
|
|
|
let response = format!("Pong! (latency: {} ms)", system_now - message_now);
|
|
ctx.say(response).await?;
|
|
|
|
Ok(())
|
|
}
|