large refactor: reorganize code

This commit is contained in:
2024-10-11 20:33:12 -04:00
parent ecbf4cad06
commit 4e08e25575
10 changed files with 240 additions and 183 deletions

17
src/commands/ping.rs Normal file
View File

@@ -0,0 +1,17 @@
use crate::common::{Context, Error};
/// Display the bot's latency to Discord's REST and Gateway APIs
#[poise::command(slash_command, prefix_command)]
pub async fn ping(ctx: Context<'_>) -> Result<(), Error> {
use std::time::Instant;
let start = Instant::now();
let msg = ctx.say("Pong! \u{1F3D3}").await?;
let time = start.elapsed();
msg.edit(ctx, poise::reply::CreateReply::default()
.content(format!("Pong! \u{1F3D3}\nREST: {:.2?}\nGateway: {:.2?}",
time, ctx.ping().await))).await?;
Ok(())
}