mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 13:56:43 +02:00
Add smash ultimate support to challenger
This commit is contained in:
|
Before Width: | Height: | Size: 294 KiB After Width: | Height: | Size: 294 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 442 KiB |
@@ -4,6 +4,18 @@ const { createCanvas, loadImage } = require('canvas');
|
|||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { silhouette, hasAlpha, centerImagePart } = require('../../util/Canvas');
|
const { silhouette, hasAlpha, centerImagePart } = require('../../util/Canvas');
|
||||||
|
const games = {
|
||||||
|
ultimate: {
|
||||||
|
x: 645,
|
||||||
|
y: 132,
|
||||||
|
size: 400
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
x: 484,
|
||||||
|
y: 98,
|
||||||
|
size: 256
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = class ChallengerCommand extends Command {
|
module.exports = class ChallengerCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -22,9 +34,15 @@ module.exports = class ChallengerCommand extends Command {
|
|||||||
{
|
{
|
||||||
name: 'Jack The Awesomeness Gamer',
|
name: 'Jack The Awesomeness Gamer',
|
||||||
url: 'https://www.youtube.com/channel/UCIeA23B91hAeR1UuC2VDSdQ',
|
url: 'https://www.youtube.com/channel/UCIeA23B91hAeR1UuC2VDSdQ',
|
||||||
reason: 'Image',
|
reason: 'Smash 4 Image',
|
||||||
reasonURL: 'https://www.youtube.com/watch?v=3FebRrXg0bk'
|
reasonURL: 'https://www.youtube.com/watch?v=3FebRrXg0bk'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'MatthewThePrep',
|
||||||
|
url: 'https://www.deviantart.com/matthewtheprep',
|
||||||
|
reason: 'Ultimate Image',
|
||||||
|
reasonURL: 'https://www.deviantart.com/matthewtheprep/art/SSBU-Challenger-Approaching-meme-template-800422972'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Nintendo',
|
name: 'Nintendo',
|
||||||
url: 'https://www.nintendo.com/',
|
url: 'https://www.nintendo.com/',
|
||||||
@@ -43,6 +61,12 @@ module.exports = class ChallengerCommand extends Command {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
|
{
|
||||||
|
key: 'game',
|
||||||
|
type: 'string',
|
||||||
|
oneOf: Object.keys(games),
|
||||||
|
parse: game => game.toLowerCase()
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'image',
|
key: 'image',
|
||||||
type: 'image-or-avatar',
|
type: 'image-or-avatar',
|
||||||
@@ -52,15 +76,16 @@ module.exports = class ChallengerCommand extends Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { image, flags }) {
|
async run(msg, { game, image, flags }) {
|
||||||
const silhouetted = !(flags.show || flags.s);
|
const silhouetted = !(flags.show || flags.s);
|
||||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger.png'));
|
const gameData = games[game];
|
||||||
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger', `${game}.png`));
|
||||||
const { body } = await request.get(image);
|
const { body } = await request.get(image);
|
||||||
const data = await loadImage(body);
|
const data = await loadImage(body);
|
||||||
const canvas = createCanvas(base.width, base.height);
|
const canvas = createCanvas(base.width, base.height);
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.drawImage(base, 0, 0);
|
ctx.drawImage(base, 0, 0);
|
||||||
const { x, y, width, height } = centerImagePart(data, 256, 256, 484, 98);
|
const { x, y, width, height } = centerImagePart(data, gameData.size, gameData.size, gameData.x, gameData.y);
|
||||||
ctx.drawImage(silhouetted ? this.silhouetteImage(data) : data, x, y, width, height);
|
ctx.drawImage(silhouetted ? this.silhouetteImage(data) : data, x, y, width, height);
|
||||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'challenger.png' }] });
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'challenger.png' }] });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user