diff --git a/assets/images/be-like-bill.png b/assets/images/be-like-bill.png index 51f88b9d..995e9a50 100644 Binary files a/assets/images/be-like-bill.png and b/assets/images/be-like-bill.png differ diff --git a/assets/images/dexter.png b/assets/images/dexter.png index 607ae359..2da466ea 100644 Binary files a/assets/images/dexter.png and b/assets/images/dexter.png differ diff --git a/assets/images/food-broke.png b/assets/images/food-broke.png new file mode 100644 index 00000000..a7364d13 Binary files /dev/null and b/assets/images/food-broke.png differ diff --git a/assets/images/i-have-the-power.png b/assets/images/i-have-the-power.png index 130de274..1fec9a00 100644 Binary files a/assets/images/i-have-the-power.png and b/assets/images/i-have-the-power.png differ diff --git a/assets/images/look-at-this-photograph.png b/assets/images/look-at-this-photograph.png index 0ca2400d..5f885059 100644 Binary files a/assets/images/look-at-this-photograph.png and b/assets/images/look-at-this-photograph.png differ diff --git a/commands/avatar-edit/food-broke.js b/commands/avatar-edit/food-broke.js new file mode 100644 index 00000000..fe8b2135 --- /dev/null +++ b/commands/avatar-edit/food-broke.js @@ -0,0 +1,50 @@ +const { Command } = require('discord.js-commando'); +const { createCanvas, loadImage } = require('canvas'); +const snekfetch = require('snekfetch'); +const path = require('path'); + +module.exports = class FoodBrokeCommand extends Command { + constructor(client) { + super(client, { + name: 'food-broke', + aliases: ['food-machine-broke'], + group: 'avatar-edit', + memberName: 'food-broke', + description: 'Draws a user\'s avatar over the "Food Broke" meme.', + throttling: { + usages: 1, + duration: 15 + }, + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'user', + prompt: 'Which user would you like to edit the avatar of?', + type: 'user', + default: '' + } + ] + }); + } + + async run(msg, { user }) { + if (!user) user = msg.author; + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 128 + }); + try { + const canvas = createCanvas(680, 680); + const ctx = canvas.getContext('2d'); + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'food-broke.png')); + const { body } = await snekfetch.get(avatarURL); + const avatar = await loadImage(body); + ctx.drawImage(base, 0, 0); + ctx.drawImage(avatar, 23, 9, 125, 125); + ctx.drawImage(avatar, 117, 382, 75, 75); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'food-broke.png' }] }); + } catch (err) { + return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 44abd14e..d03a408e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "46.1.3", + "version": "46.2.0", "description": "Your personal server companion.", "main": "Shard.js", "scripts": {