Chocolate Milk Command

This commit is contained in:
Dragon Fire
2020-05-18 13:36:28 -04:00
parent bc76f87147
commit 08de0201a2
4 changed files with 62 additions and 2 deletions
+2 -1
View File
@@ -136,7 +136,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 423
Total: 424
### Utility:
@@ -465,6 +465,7 @@ Total: 423
* **avatar-fusion:** Draws a a user's avatar over a user's avatar.
* **bob-ross:** Draws a user's avatar over Bob Ross' canvas.
* **chocolate-milk:** Draws a user's avatar holding chocolate milk.
* **hat:** Draws a hat over a user's avatar.
* **he-lives-in-you:** Draws a user's avatar over Simba from The Lion King's reflection.
* **hearts:** Draws hearts around a user's avatar.
Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

+59
View File
@@ -0,0 +1,59 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage } = require('canvas');
const request = require('node-superfetch');
const path = require('path');
module.exports = class ChocolateMilkCommand extends Command {
constructor(client) {
super(client, {
name: 'chocolate-milk',
aliases: ['milk', 'sip-milk', 'sip-chocolate-milk', 'choccy', 'sip-choccy'],
group: 'edit-avatar',
memberName: 'chocolate-milk',
description: 'Draws a user\'s avatar holding chocolate milk.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
args: [
{
key: 'user',
prompt: 'Which user would you like to edit the avatar of?',
type: 'user',
default: msg => msg.author
},
{
key: 'direction',
prompt: 'What direction should the avatar face?',
type: 'string',
oneOf: ['left', 'right'],
default: 'left',
parse: direction => direction.toLowerCase()
}
]
});
}
async run(msg, { user, direction }) {
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
try {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'chocolate-milk.png'));
const { body } = await request.get(avatarURL);
const avatar = await loadImage(body);
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.fillRect(0, 0, base.width, base.height);
if (direction === 'right') {
ctx.translate(base.width, 0);
ctx.scale(-1, 1);
}
ctx.drawImage(avatar, 0, 0, 512, 512);
if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.drawImage(base, 0, 0);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'chocolate-milk.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "114.14.0",
"version": "114.15.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {