Reorganize Uptime code
This commit is contained in:
parent
23d3166c2d
commit
480ea3bd82
1 changed files with 14 additions and 14 deletions
|
|
@ -7,20 +7,6 @@ use crate::api::Message;
|
||||||
use crate::bot::command::{ClapCommand, Context};
|
use crate::bot::command::{ClapCommand, Context};
|
||||||
use crate::conn;
|
use crate::conn;
|
||||||
|
|
||||||
/// Show how long the bot has been online.
|
|
||||||
#[derive(Parser)]
|
|
||||||
pub struct Args {
|
|
||||||
/// Show how long the bot has been connected without interruption.
|
|
||||||
#[arg(long, short)]
|
|
||||||
connected: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Uptime;
|
|
||||||
|
|
||||||
pub trait HasStartTime {
|
|
||||||
fn start_time(&self) -> OffsetDateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn format_time(t: OffsetDateTime) -> String {
|
pub fn format_time(t: OffsetDateTime) -> String {
|
||||||
let t = t.to_offset(UtcOffset::UTC);
|
let t = t.to_offset(UtcOffset::UTC);
|
||||||
let format = format_description!("[year]-[month]-[day] [hour]:[minute]:[second] UTC");
|
let format = format_description!("[year]-[month]-[day] [hour]:[minute]:[second] UTC");
|
||||||
|
|
@ -59,6 +45,20 @@ pub fn format_duration(d: Duration) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Uptime;
|
||||||
|
|
||||||
|
pub trait HasStartTime {
|
||||||
|
fn start_time(&self) -> OffsetDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Show how long the bot has been online.
|
||||||
|
#[derive(Parser)]
|
||||||
|
pub struct Args {
|
||||||
|
/// Show how long the bot has been connected without interruption.
|
||||||
|
#[arg(long, short)]
|
||||||
|
connected: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<B, E> ClapCommand<B, E> for Uptime
|
impl<B, E> ClapCommand<B, E> for Uptime
|
||||||
where
|
where
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue