ping command
This commit is contained in:
parent
e395886f6c
commit
bb4c96a628
@ -10,9 +10,8 @@ use serenity::{
|
|||||||
framework::standard::CommandResult,
|
framework::standard::CommandResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
use chrono_tz::Tz;
|
|
||||||
|
|
||||||
use chrono::offset::Utc;
|
use chrono::offset::Utc;
|
||||||
|
use chrono_tz::Tz;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
THEME_COLOR,
|
THEME_COLOR,
|
||||||
@ -20,6 +19,25 @@ use crate::{
|
|||||||
models::UserData,
|
models::UserData,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use std::time::{
|
||||||
|
SystemTime,
|
||||||
|
UNIX_EPOCH
|
||||||
|
};
|
||||||
|
|
||||||
|
#[command]
|
||||||
|
#[can_blacklist(false)]
|
||||||
|
async fn ping(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
||||||
|
let now = SystemTime::now();
|
||||||
|
let since_epoch = now
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.expect("Time calculated as going backwards. Very bad");
|
||||||
|
|
||||||
|
let delta = since_epoch.as_millis() as i64 - msg.timestamp.timestamp_millis();
|
||||||
|
|
||||||
|
let _ = msg.channel_id.say(&ctx, format!("Time taken to receive message: {}ms", delta)).await;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[can_blacklist(false)]
|
#[can_blacklist(false)]
|
||||||
|
@ -118,6 +118,8 @@ SELECT code FROM languages WHERE code = ? OR name = ?
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
|
#[supports_dm(false)]
|
||||||
|
#[permission_level(Restricted)]
|
||||||
async fn prefix(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn prefix(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||||
let pool = ctx.data.read().await
|
let pool = ctx.data.read().await
|
||||||
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
||||||
|
@ -24,6 +24,8 @@ use chrono::NaiveDateTime;
|
|||||||
|
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
|
#[supports_dm(false)]
|
||||||
|
#[permission_level(Restricted)]
|
||||||
async fn pause(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn pause(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||||
let pool = ctx.data.read().await
|
let pool = ctx.data.read().await
|
||||||
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
||||||
@ -68,6 +70,7 @@ async fn pause(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
|
#[permission_level(Restricted)]
|
||||||
async fn offset(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn offset(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||||
let pool = ctx.data.read().await
|
let pool = ctx.data.read().await
|
||||||
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
||||||
@ -118,6 +121,7 @@ UPDATE reminders SET `time` = `time` + ? WHERE reminders.channel_id = ?
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
|
#[permission_level(Restricted)]
|
||||||
async fn nudge(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn nudge(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||||
let pool = ctx.data.read().await
|
let pool = ctx.data.read().await
|
||||||
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
||||||
|
@ -58,6 +58,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||||||
let framework = RegexFramework::new(env::var("CLIENT_ID").expect("Missing CLIENT_ID from environment").parse()?)
|
let framework = RegexFramework::new(env::var("CLIENT_ID").expect("Missing CLIENT_ID from environment").parse()?)
|
||||||
.ignore_bots(true)
|
.ignore_bots(true)
|
||||||
.default_prefix("$")
|
.default_prefix("$")
|
||||||
|
|
||||||
|
.add_command("ping", &info_cmds::PING_COMMAND)
|
||||||
|
|
||||||
.add_command("help", &info_cmds::HELP_COMMAND)
|
.add_command("help", &info_cmds::HELP_COMMAND)
|
||||||
.add_command("info", &info_cmds::INFO_COMMAND)
|
.add_command("info", &info_cmds::INFO_COMMAND)
|
||||||
.add_command("donate", &info_cmds::DONATE_COMMAND)
|
.add_command("donate", &info_cmds::DONATE_COMMAND)
|
||||||
|
Loading…
Reference in New Issue
Block a user