Skip to content

Commit

Permalink
feat: display manga count on status
Browse files Browse the repository at this point in the history
  • Loading branch information
j1nxie committed Dec 12, 2024
1 parent 5b79da6 commit cd06a15
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/commands/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ use std::time::UNIX_EPOCH;
use crate::{
commands::get_bot_avatar,
constants::{version::get_version, POISE_VERSION, STARTUP_TIME},
models::prelude::Manga,
Context, Error,
};
use poise::serenity_prelude as serenity;
use sea_orm::{EntityTrait, PaginatorTrait};

/// get the bot's status.
#[poise::command(prefix_command)]
#[tracing::instrument(skip_all)]
pub async fn status(ctx: Context<'_>) -> Result<(), Error> {
let count = Manga::find().count(&ctx.data().db).await.inspect_err(
|e| tracing::error!(err = ?e, "an error occurred when fetching manga from database"),
)?;

ctx.send(poise::CreateReply::default().embed(
serenity::CreateEmbed::new()
.field(
Expand All @@ -21,6 +27,7 @@ pub async fn status(ctx: Context<'_>) -> Result<(), Error> {
.field("version", get_version(), false)
.field("rust", format!("[{0}](https://releases.rs/docs/{0})", rustc_version_runtime::version().to_string()), true)
.field("poise", format!("[{0}](https://docs.rs/crate/poise/{0})", POISE_VERSION), true)
.field("manga titles tracked", format!("{}", count), true)
.field("uptime", format!("<t:{}:R>", STARTUP_TIME.duration_since(UNIX_EPOCH).unwrap().as_secs()), true)
.thumbnail(get_bot_avatar(ctx))
))
Expand Down

0 comments on commit cd06a15

Please sign in to comment.