Yu Gi Oh Token

This commit is contained in:
Daniel Odendahl Jr
2017-09-09 19:18:31 +00:00
parent 095c10f870
commit 1d5e5298b6
3 changed files with 49 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

+48
View File
@@ -0,0 +1,48 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage } = require('canvas');
const snekfetch = require('snekfetch');
const path = require('path');
module.exports = class YuGiOhTokenCommand extends Command {
constructor(client) {
super(client, {
name: 'yu-gi-oh-token',
group: 'avatar-edit',
memberName: 'yu-gi-oh-token',
description: 'Draws a user\'s avatar over a blank Yu-Gi-Oh! token.',
throttling: {
usages: 1,
duration: 30
},
clientPermissions: ['ATTACH_FILES'],
args: [
{
key: 'user',
prompt: 'Which user would you like to edit the avatar of?',
type: 'user',
default: ''
}
]
});
}
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 512
});
try {
const canvas = createCanvas(384, 564);
const ctx = canvas.getContext('2d');
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'yu-gi-oh-token.png'));
const { body } = await snekfetch.get(avatarURL);
const avatar = await loadImage(body);
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 45, 102, 293, 294);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'yu-gi-oh-token.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",
"version": "38.0.3",
"version": "38.1.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {