yugiohtoken accepts images

This commit is contained in:
Dragon Fire
2020-06-14 23:53:47 -04:00
parent 3b57513a81
commit 5dcd367a56
3 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -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 })
}
]
});
@@ -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!`);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "116.27.1",
"version": "116.27.2",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {