Add !pfp command

This commit is contained in:
Agatha Lovelace 2020-06-14 00:48:06 +03:00
parent 5ead7e570c
commit e787656ef0
No known key found for this signature in database
GPG Key ID: 2DB18BA2E0A80BC3
1 changed files with 26 additions and 1 deletions

View File

@ -55,7 +55,7 @@ impl EventHandler for Handler {
#[group] #[group]
#[commands( #[commands(
init, ping, halt, servers, host, status, ship, bottom_rng, headpat, uwu, gayculator, sausage, 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; struct General;
@ -613,6 +613,7 @@ fn help(ctx: &mut Context, message: &Message) -> CommandResult {
"Display channel's Nth pinned message. Channel name is optional", "Display channel's Nth pinned message. Channel name is optional",
true, true,
), ),
("owo!pfp ``@username``", "Post user's profile picture", true),
("owo!brainfuck ``input``", "Execute input code", true), ("owo!brainfuck ``input``", "Execute input code", true),
("owo!ship ``[names]``", "*Shipping intensifies*", true), ("owo!ship ``[names]``", "*Shipping intensifies*", true),
("owo!headpat ``name``", "Headpat someone", true), ("owo!headpat ``name``", "Headpat someone", true),
@ -689,6 +690,30 @@ fn define(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
Ok(()) 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 // Text owoification
#[command] #[command]
fn owo(ctx: &mut Context, message: &Message, args: Args) -> CommandResult { fn owo(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {