mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Yu Gi Oh Token
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 170 KiB |
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "38.0.3",
|
||||
"version": "38.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user