forked from sorceress/rustcord
Add !pfp command
This commit is contained in:
parent
5ead7e570c
commit
e787656ef0
27
src/main.rs
27
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 {
|
||||
|
|
Loading…
Reference in New Issue