From 5dcd367a56029487600d9dcf4bbdaa12db6afbe3 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 14 Jun 2020 23:53:47 -0400 Subject: [PATCH] yugiohtoken accepts images --- commands/edit-image/yu-gi-oh-gen.js | 2 +- .../yu-gi-oh-token.js | 22 +++++++++---------- package.json | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) rename commands/{edit-avatar => edit-image}/yu-gi-oh-token.js (71%) diff --git a/commands/edit-image/yu-gi-oh-gen.js b/commands/edit-image/yu-gi-oh-gen.js index 269dc953..e6dc89d7 100644 --- a/commands/edit-image/yu-gi-oh-gen.js +++ b/commands/edit-image/yu-gi-oh-gen.js @@ -102,7 +102,7 @@ module.exports = class YuGiOhGenCommand extends Command { key: 'image', prompt: 'What image would you like to edit?', type: 'image', - default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 }) + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 1024 }) } ] }); diff --git a/commands/edit-avatar/yu-gi-oh-token.js b/commands/edit-image/yu-gi-oh-token.js similarity index 71% rename from commands/edit-avatar/yu-gi-oh-token.js rename to commands/edit-image/yu-gi-oh-token.js index 767f927f..aea71eff 100644 --- a/commands/edit-avatar/yu-gi-oh-token.js +++ b/commands/edit-image/yu-gi-oh-token.js @@ -8,9 +8,9 @@ module.exports = class YuGiOhTokenCommand extends Command { super(client, { name: 'yu-gi-oh-token', aliases: ['ygo-token'], - group: 'edit-avatar', + group: 'edit-image', memberName: 'yu-gi-oh-token', - description: 'Draws a user\'s avatar over a blank Yu-Gi-Oh! Token card.', + description: 'Draws an image or a user\'s avatar over a blank Yu-Gi-Oh! Token card.', throttling: { usages: 1, duration: 10 @@ -26,27 +26,27 @@ module.exports = class YuGiOhTokenCommand extends Command { ], args: [ { - key: 'user', - prompt: 'Which user would you like to edit the avatar of?', - type: 'user', - default: msg => msg.author + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] }); } - async run(msg, { user }) { - const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 }); + async run(msg, { image }) { try { const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'yu-gi-oh-token.png')); - const { body } = await request.get(avatarURL); - const avatar = await loadImage(body); + const { body } = await request.get(image); + const data = await loadImage(body); const canvas = createCanvas(base.width, base.height); const ctx = canvas.getContext('2d'); ctx.fillStyle = 'white'; ctx.fillRect(0, 0, base.width, base.height); ctx.drawImage(base, 0, 0); - ctx.drawImage(avatar, 45, 102, 293, 294); + const height = 294 / data.width; + ctx.drawImage(data, 45, 102, 294, data.height * height); return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'yu-gi-oh-token.png' }] }); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/package.json b/package.json index 9e979769..886aebba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.27.1", + "version": "116.27.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {