feat: petpet comamnd the lazyway

Changed files
+44
src
commands
+1
src/commands/fun/mod.rs
··· 2 2 pub mod chance; 3 3 pub mod kittysay; 4 4 pub mod nix; 5 + pub mod pet;
+42
src/commands/fun/pet.rs
··· 1 + use crate::types::Context; 2 + use color_eyre::eyre::Result; 3 + use poise::{serenity_prelude::all::User, CreateReply}; 4 + use serenity::all::CreateAttachment; 5 + 6 + #[derive(serde::Serialize, serde::Deserialize)] 7 + struct PetPet { 8 + image: String, 9 + } 10 + 11 + /// Displays your or another user's info 12 + #[poise::command(slash_command)] 13 + pub async fn pet( 14 + ctx: Context<'_>, 15 + #[description = "Selected user"] user: Option<User>, 16 + ) -> Result<()> { 17 + let user = user.as_ref().unwrap_or_else(|| ctx.author()); 18 + 19 + let pet = PetPet { 20 + image: user 21 + .avatar_url() 22 + .expect("avatar failed") 23 + .replace("webp", "png"), 24 + }; 25 + 26 + let res = ctx 27 + .data() 28 + .client 29 + .get("https://memeado.vercel.app/api/petpet") 30 + .json(&pet) 31 + .send() 32 + .await? 33 + .bytes() 34 + .await?; 35 + 36 + let attachment = CreateAttachment::bytes(res, "petpet.gif"); 37 + 38 + let reply = CreateReply::default().attachment(attachment); 39 + 40 + ctx.send(reply).await?; 41 + Ok(()) 42 + }
+1
src/main.rs
··· 46 46 commands::fun::kittysay::kittysay(), 47 47 commands::fun::bottom::topify(), 48 48 commands::fun::bottom::bottomify(), 49 + commands::fun::pet::pet(), 49 50 ], 50 51 event_handler: |ctx, event, _, data| { 51 52 Box::pin(crate::event_handler::event_handler(ctx, event, data))