Food Broke Command

This commit is contained in:
Daniel Odendahl Jr
2017-10-10 01:25:30 +00:00
parent 495434c1f7
commit a97b5f7562
7 changed files with 51 additions and 1 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 356 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 254 KiB

+50
View File
@@ -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!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiaobot", "name": "xiaobot",
"version": "46.1.3", "version": "46.2.0",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Shard.js", "main": "Shard.js",
"scripts": { "scripts": {