From a1876d5a6d47f9bf8fb78be4162d6a7d7fa90d16 Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 2 May 2024 20:29:12 -0400 Subject: feat: add pfp command --- src/commands/general/bing.rs | 2 -- src/commands/general/mod.rs | 1 + src/commands/general/pfp.rs | 24 ++++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/commands/general/pfp.rs (limited to 'src/commands/general') diff --git a/src/commands/general/bing.rs b/src/commands/general/bing.rs index d58404e..54ee0dc 100644 --- a/src/commands/general/bing.rs +++ b/src/commands/general/bing.rs @@ -1,7 +1,5 @@ use crate::{Context, Error}; -use eyre::Result; - /// Make sure the wie is alive #[poise::command(prefix_command)] pub async fn bing(ctx: Context<'_>) -> Result<(), Error> { diff --git a/src/commands/general/mod.rs b/src/commands/general/mod.rs index 82af4d2..9bd3827 100644 --- a/src/commands/general/mod.rs +++ b/src/commands/general/mod.rs @@ -2,5 +2,6 @@ pub mod ask; pub mod bing; pub mod config; pub mod convert; +pub mod pfp; pub mod random; pub mod version; diff --git a/src/commands/general/pfp.rs b/src/commands/general/pfp.rs new file mode 100644 index 0000000..2ad062b --- /dev/null +++ b/src/commands/general/pfp.rs @@ -0,0 +1,24 @@ +use poise::{ + serenity_prelude::{CreateEmbed, User}, + CreateReply, +}; + +use crate::{consts::Colors, Context, Error}; + +/// Get someone's profile pic +#[poise::command(context_menu_command = "Get profile picture", slash_command)] +pub async fn pfp(ctx: Context<'_>, user: User) -> Result<(), Error> { + let url = user + .avatar_url() + .unwrap_or_else(|| user.default_avatar_url()); + let embed = CreateEmbed::new() + .title(user.name) + .color(Colors::Blue) + .url(&url) + .image(&url); + let reply = CreateReply::default().embed(embed); + + ctx.send(reply).await?; + + Ok(()) +} -- cgit v1.2.3