List task command + updated deps

This commit is contained in:
joeyahines committed 2024-03-04 19:52:53 -07:00
1 parent c08ec0120d
commit 83efbb0d4f
6 files changed
+255 -95

No files matched your search

+31 -2
View File
@@ -5,15 +5,18 @@ use crate::models::lil_fren::{
draw_dancing, draw_frankenstein, draw_gone, draw_magic, draw_mining, draw_resonance_cascade,
draw_sick, draw_sleep, draw_standing, draw_tax_fraud, AliveState, LilFren,
};
use crate::models::task::Task;
use crate::user::User;
use crate::{command, group, GlobalData};
use json::JsonValue;
use serenity::all::{CreateAttachment, CreateMessage};
use serenity::all::{CreateAttachment, CreateMessage, FormattedTimestamp, FormattedTimestampStyle};
use serenity::client::Context;
use serenity::framework::standard::{Args, CommandResult};
use serenity::model::channel::Message;
use serenity::model::misc::EmojiIdentifier;
use serenity::model::prelude::UserId;
use serenity::model::Timestamp;
use serenity::utils::MessageBuilder;
use std::borrow::Cow;
#[group]
@@ -24,7 +27,8 @@ use std::borrow::Cow;
add_key,
debug_buddy,
draw_buddy_states,
op_give
op_give,
list_tasks
)]
pub struct ADMIN;
@@ -240,3 +244,28 @@ async fn op_give(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
Ok(())
}
#[command]
#[description("List scheduled tasks")]
async fn list_tasks(ctx: &Context, msg: &Message) -> CommandResult {
let data = ctx.data.read().await;
let global_data = data.get::<GlobalData>().unwrap();
let tasks: Vec<Task> = global_data.db.filter(|_, _task: &Task| true)?.collect();
let mut resp = MessageBuilder::new();
for task in &tasks {
let timestamp = Timestamp::from(task.time);
let time_tag =
FormattedTimestamp::new(timestamp, Some(FormattedTimestampStyle::ShortDateTime));
resp.push_line(format!(
"* **Task**: {:?} **Next Execution**: {}",
task.task_type, time_tag
));
}
msg.reply(&ctx.http, resp.build()).await?;
Ok(())
}
+2 -2
View File
@@ -42,7 +42,7 @@ pub async fn create_motivation_image(motivation: Motivation) -> Result<Vec<u8>,
&border_wand,
border,
border,
magick_rust::bindings::CompositeOperator_OverCompositeOp,
magick_rust::bindings::CompositeOperator_OverCompositeOp.into(),
)?;
border_wand.set_color("black")?;
@@ -52,7 +52,7 @@ pub async fn create_motivation_image(motivation: Motivation) -> Result<Vec<u8>,
&border_wand,
border,
border,
magick_rust::bindings::CompositeOperator_OverCompositeOp,
magick_rust::bindings::CompositeOperator_OverCompositeOp.into(),
)?;
let text_pos_x = wand.get_image_width() as f64 / 2.0;