Metamorphosis Command

This commit is contained in:
Dragon Fire
2020-07-13 20:26:57 -04:00
parent b042db6449
commit d6a2694969
4 changed files with 83 additions and 1 deletions
+5
View File
@@ -1115,6 +1115,7 @@ here.
* map ([Maps Static API](https://developers.google.com/maps/documentation/maps-static/intro))
* mario-bros-views ([Noto Font](https://www.google.com/get/noto/))
* meme-gen-modern ([Noto Font](https://www.google.com/get/noto/))
* metamorphosis ([Noto Font](https://www.google.com/get/noto/))
* new-password ([Noto Font](https://www.google.com/get/noto/))
* nike-ad ([Noto Font](https://www.google.com/get/noto/))
* panik-kalm-panik ([Noto Font](https://www.google.com/get/noto/))
@@ -1294,6 +1295,8 @@ here.
* horse-race ([Horse Name Data](https://horses.lovetoknow.com/horse-names/funny-horse-names))
- [LowGif](http://www.lowgif.com/)
* fire ([Images](http://www.lowgif.com/43360ebce9150f23.html))
- [LuckyAquapura](https://twitter.com/alcremimiga)
* metamorphosis (Concept)
- [Luxoflux](http://www.luxoflux.com/)
* gun ([Image](https://knowyourmeme.com/memes/hand-pointing-a-gun))
- [Mad Libs](http://www.madlibs.com/)
@@ -1715,6 +1718,8 @@ here.
* xkcd ([API](https://xkcd.com/json.html))
- [Yahoo](https://www.yahoo.com/)
* stocks (Finance API)
- [Yeah I'm Stuck in the Void, Keep Scrolling](https://www.facebook.com/voidmanthing/)
* metamorphosis ([Image](https://www.facebook.com/voidmanthing/posts/125724262420450))
- [YGOPRODECK](https://ygoprodeck.com/)
* yu-gi-oh ([API](https://db.ygoprodeck.com/api-guide/))
- [YorkAARGH](https://github.com/YorkAARGH)
Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

+77
View File
@@ -0,0 +1,77 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage, registerFont } = require('canvas');
const request = require('node-superfetch');
const path = require('path');
const { centerImagePart } = require('../../util/Canvas');
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
module.exports = class MetamorphosisCommand extends Command {
constructor(client) {
super(client, {
name: 'metamorphosis',
aliases: ['my-metamorphosis-begins', 'morph'],
group: 'edit-meme',
memberName: 'metamorphosis',
description: 'Sends a "My Metamorphosis Begins" meme with the image and text of your choice.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Google',
url: 'https://www.google.com/',
reason: 'Noto Font',
reasonURL: 'https://www.google.com/get/noto/'
},
{
name: 'LuckyAquapura',
url: 'https://twitter.com/alcremimiga',
reason: 'Concept'
},
{
name: 'Yeah I\'m Stuck in the Void, Keep Scrolling',
url: 'https://www.facebook.com/voidmanthing/',
reason: 'Image',
reasonURL: 'https://www.facebook.com/voidmanthing/posts/125724262420450'
}
],
args: [
{
key: 'name',
prompt: 'What is the name of thing to morph into?',
type: 'string',
max: 280
},
{
key: 'image',
prompt: 'What image would you like to edit?',
type: 'image',
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
}
]
});
}
async run(msg, { name, image }) {
try {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'metamorphosis.png'));
const { body } = await request.get(image);
const data = await loadImage(body);
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
const { x, y, width, height } = centerImagePart(data, 200, 200, 412, 257);
ctx.drawImage(data, x, y, width, height);
ctx.textBaseline = 'top';
ctx.font = '20px Noto';
ctx.fillText(`le ${name.toLowerCase()}`, 345, 466, 330);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'metamorphosis.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": "119.16.1",
"version": "119.17.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {