Hearts Command

This commit is contained in:
Daniel Odendahl Jr
2019-02-09 02:15:06 +00:00
parent f17f6bbe0f
commit a4a0c8f75d
4 changed files with 49 additions and 2 deletions
+2 -1
View File
@@ -47,7 +47,7 @@ Xiao is a Discord bot coded in JavaScript with
7. Run `npm i -g pm2` to install PM2.
8. Run `pm2 start Xiao.js --name xiao` to run the bot.
## Commands (331)
## Commands (332)
### Utility:
* **eval:** Executes JavaScript code.
@@ -330,6 +330,7 @@ Xiao is a Discord bot coded in JavaScript with
* **girl-worth-fighting-for:** Draws a user's avatar as the object of Ling's affection.
* **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.
* **i-have-the-power:** Draws a user's avatar over He-Man's face.
* **look-at-this-photograph:** Draws a user's avatar over Nickelback's photograph.
* **look-what-karen-have:** Draws a user's avatar over Karen's piece of paper.
Binary file not shown.

After

Width:  |  Height:  |  Size: 750 KiB

+46
View File
@@ -0,0 +1,46 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage } = require('canvas');
const request = require('node-superfetch');
const path = require('path');
const { drawImageWithTint } = require('../../util/Canvas');
module.exports = class HeartsCommand extends Command {
constructor(client) {
super(client, {
name: 'hearts',
aliases: ['heart'],
group: 'avatar-edit',
memberName: 'hearts',
description: 'Draws hearts around a user\'s avatar.',
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
}
]
});
}
async run(msg, { user }) {
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
try {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'hearts.png'));
const { body } = await request.get(avatarURL);
const avatar = await loadImage(body);
const canvas = createCanvas(avatar.width, avatar.height);
const ctx = canvas.getContext('2d');
drawImageWithTint(ctx, avatar, 'pink', 0, 0, avatar.width, avatar.height);
ctx.drawImage(base, 0, 0, avatar.width, avatar.height);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'hearts.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": "101.0.2",
"version": "101.1.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {