mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-13 00:09:08 +02:00
Test
This commit is contained in:
@@ -135,34 +135,12 @@ module.exports = class HatCommand extends Command {
|
|||||||
prompt: 'Which user would you like to edit the avatar of?',
|
prompt: 'Which user would you like to edit the avatar of?',
|
||||||
type: 'user',
|
type: 'user',
|
||||||
default: msg => msg.author
|
default: msg => msg.author
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'addX',
|
|
||||||
prompt: 'How far do you want to move the hat on the X-Axis?',
|
|
||||||
type: 'integer',
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'addY',
|
|
||||||
prompt: 'How far do you want to move the hat on the Y-Axis?',
|
|
||||||
type: 'integer',
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'scale',
|
|
||||||
prompt: 'By what percentage do you want to scale your hat?',
|
|
||||||
type: 'integer',
|
|
||||||
min: 0,
|
|
||||||
max: 1000,
|
|
||||||
default: 0
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { type, user, addX, addY, scale }) {
|
async run(msg, { type, user }) {
|
||||||
scale /= 100;
|
|
||||||
if (scale === 0) scale = 1;
|
|
||||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||||
try {
|
try {
|
||||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'hat', `${type}.png`));
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'hat', `${type}.png`));
|
||||||
@@ -171,7 +149,7 @@ module.exports = class HatCommand extends Command {
|
|||||||
const canvas = createCanvas(avatar.width, avatar.height);
|
const canvas = createCanvas(avatar.width, avatar.height);
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.drawImage(avatar, 0, 0);
|
ctx.drawImage(avatar, 0, 0);
|
||||||
ctx.drawImage(base, 0 + addX, 0 + addY, avatar.width * scale, avatar.height * scale);
|
ctx.drawImage(base, 0, 0, avatar.width, avatar.height);
|
||||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: `${type}-hat.png` }] });
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: `${type}-hat.png` }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
|||||||
Reference in New Issue
Block a user