better use of use

This commit is contained in:
2024-10-11 20:52:24 -04:00
parent 0cd900c67a
commit 0a4be91cd2

View File

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