From a088476f96c4e5b5b1f22121f64a10d9cd2ae847 Mon Sep 17 00:00:00 2001 From: roflmaoqwerty Date: Wed, 15 Jan 2020 00:41:20 +1100 Subject: [PATCH] added avatar command --- backend/src/plugins/Utility.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/backend/src/plugins/Utility.ts b/backend/src/plugins/Utility.ts index a3f7a39f..8779046a 100644 --- a/backend/src/plugins/Utility.ts +++ b/backend/src/plugins/Utility.ts @@ -84,6 +84,7 @@ const ConfigSchema = t.type({ can_context: t.boolean, can_jumbo: t.boolean, jumbo_size: t.Integer, + can_avatar: t.boolean, }); type TConfigSchema = t.TypeOf; @@ -149,6 +150,7 @@ export class UtilityPlugin extends ZeppelinPlugin { can_context: false, can_jumbo: false, jumbo_size: 128, + can_avatar: false, }, overrides: [ { @@ -165,6 +167,7 @@ export class UtilityPlugin extends ZeppelinPlugin { can_help: true, can_context: true, can_jumbo: true, + can_avatar: true, }, }, { @@ -1528,6 +1531,28 @@ export class UtilityPlugin extends ZeppelinPlugin { return; } + @d.command("avatar", "[user:resolvedUserLoose]", { + extra: { + info: { + description: "Retrieves a users profile picture", + }, + }, + }) + @d.permission("can_avatar") + async avatarCmd(msg: Message, args: { user?: User | UnknownUser }) { + const user = args.user || msg.author; + if (!(user instanceof UnknownUser)) { + const avatarUrl = user.avatarURL.slice(0, user.avatarURL.lastIndexOf(".")); + const embed: EmbedOptions = { + image: { url: avatarUrl + ".png?size=2048" }, + }; + embed.title = `Avatar of ${user.username}#${user.discriminator}:`; + msg.channel.createMessage({ embed }); + } else { + this.sendErrorMessage(msg.channel, "Invalid user ID"); + } + } + async resizeBuffer(input: Buffer, width: number, height: number): Promise { return sharp(input, { density: 800 }) .resize(width, height, {