From e787656ef0c20f37d30c6e6a356514c8dd406623 Mon Sep 17 00:00:00 2001 From: Agatha Rose Date: Sun, 14 Jun 2020 00:48:06 +0300 Subject: [PATCH] Add !pfp command --- src/main.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 95a3624..176566c 100755 --- a/src/main.rs +++ b/src/main.rs @@ -55,7 +55,7 @@ impl EventHandler for Handler { #[group] #[commands( init, ping, halt, servers, host, status, ship, bottom_rng, headpat, uwu, gayculator, sausage, - help, embed, define, owo, info, echo, desc, pinned, brainfuck + help, embed, define, owo, info, echo, desc, pinned, brainfuck, pfp )] struct General; @@ -613,6 +613,7 @@ fn help(ctx: &mut Context, message: &Message) -> CommandResult { "Display channel's Nth pinned message. Channel name is optional", true, ), + ("owo!pfp ``@username``", "Post user's profile picture", true), ("owo!brainfuck ``input``", "Execute input code", true), ("owo!ship ``[names]``", "*Shipping intensifies*", true), ("owo!headpat ``name``", "Headpat someone", true), @@ -689,6 +690,30 @@ fn define(ctx: &mut Context, message: &Message, args: Args) -> CommandResult { Ok(()) } +#[command] +fn pfp(ctx: &mut Context, message: &Message) -> CommandResult { + // Get username from first mention, otherwise use input text + let user = match message.mentions.len() { + 0 => return Err(CommandError("Please specify a username!".to_string())), + _ => &message.mentions[0], + }; + + let pfp = match user.avatar_url() { + Some(v) => v, + None => return Err(CommandError("The user does not have an avatar".to_string())), + }; + + let _ = message.channel_id.send_message(&ctx.http, |m| { + m.embed(|e| { + e.title(format!("{}'s profile picture", user.name)) + .image(pfp) + .color(0xffd1dc) + }) + }); + + Ok(()) +} + // Text owoification #[command] fn owo(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {