From f9c33603f696a2e90f5de78c3b852dd77de0a3c9 Mon Sep 17 00:00:00 2001 From: Chen-Pang He Date: Mon, 25 Sep 2023 00:17:31 +0800 Subject: [PATCH] Update shuttle to 0.27.0 --- Cargo.toml | 7 +++---- src/fun/mod.rs | 6 ++---- src/main.rs | 10 +++------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 74547d9..3409803 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,10 +27,9 @@ rand = "0.8.5" regex = "1.9.5" reqwest = "0.11.20" serde_json = "1.0.105" -shuttle-poise = "0.26.0" -shuttle-runtime = "0.26.0" -shuttle-secrets = "0.26.0" -shuttle-static-folder = "0.26.0" +shuttle-poise = "0.27.0" +shuttle-runtime = "0.27.0" +shuttle-secrets = "0.27.0" strum = { version = "0.25", features = ["derive"] } tokio = { version = "1.32.0", features = ["full"] } tree_magic_mini = "3.0.3" diff --git a/src/fun/mod.rs b/src/fun/mod.rs index cdd4fbc..44f0f05 100644 --- a/src/fun/mod.rs +++ b/src/fun/mod.rs @@ -82,8 +82,7 @@ pub async fn cupcake(ctx: Context<'_>, ) -> anyhow::Result<()> { let target = user.as_ref().unwrap_or_else(|| ctx.author()); let face = face_image(target).await?.resize(128, 128, CatmullRom); - let path = ctx.data().assets.as_path().join("290px-Hostess-Cupcake-Whole.jpg"); - let cake = image::open(path)?.into_rgba8(); + let cake = image::open("assets/290px-Hostess-Cupcake-Whole.jpg")?.into_rgba8(); let cake: image::RgbImage = blend_image(cake, &face, 80, 80).convert(); let cake = webp::Encoder::from_rgb(&cake, cake.width(), cake.height()); @@ -210,8 +209,7 @@ pub async fn ship(ctx: Context<'_>, } async fn fuck(ctx: Context<'_>, user: Option<&serenity::User>) -> anyhow::Result<()> { - let path = ctx.data().assets.as_path().join("566424ede431200e3985ca6f21287cee.png"); - let base = image::open(path)?.into_rgba8(); + let base = image::open("assets/566424ede431200e3985ca6f21287cee.png")?.into_rgba8(); let author = face_image(ctx.author()).await?.resize(256, 256, CatmullRom); let image = blend_image(base, &author, 364, 120); let image: image::RgbImage = match user { diff --git a/src/main.rs b/src/main.rs index 38f4bc3..7354599 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,17 +5,14 @@ mod tools; mod weeb; mod topgg; use poise::serenity_prelude as serenity; -use std::path::PathBuf; #[macro_export] macro_rules! bot_id { () => { 410_315_411_695_992_833 }; } -#[derive(Debug, Default, Clone, PartialEq, Eq)] -pub struct Data { - assets: PathBuf, -} +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +pub struct Data; type Context<'a> = poise::Context<'a, Data, anyhow::Error>; @@ -62,7 +59,6 @@ fn get_commands() -> Vec> { #[shuttle_runtime::main] async fn main( - #[shuttle_static_folder::StaticFolder(folder = "assets")] path: PathBuf, #[shuttle_secrets::Secrets] secrets: shuttle_secrets::SecretStore, ) -> shuttle_poise::ShuttlePoise { let poster = topgg::Poster::new(secrets.get("TOP_GG_TOKEN")); @@ -84,7 +80,7 @@ async fn main( }, None => poise::builtins::register_globally(ctx, commands).await?, }; - Ok(Data { assets: path }) + Ok(Data) }) }) .client_settings(|client| client.event_handler(poster));