mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 08:17:35 +02:00
Shrek face Command
This commit is contained in:
@@ -1299,6 +1299,7 @@ Total: 509
|
|||||||
- [Why We Protest](https://whyweprotest.net/) ([Anon Hat Image](https://whyweprotest.net/threads/big-ass-guy-fawkes-mask-images-thread.22719/))
|
- [Why We Protest](https://whyweprotest.net/) ([Anon Hat Image](https://whyweprotest.net/threads/big-ass-guy-fawkes-mask-images-thread.22719/))
|
||||||
- [WebStockReview](https://webstockreview.net/) ([Devil Hat Image](https://webstockreview.net/explore/horn-clipart-purple-devil/))
|
- [WebStockReview](https://webstockreview.net/) ([Devil Hat Image](https://webstockreview.net/explore/horn-clipart-purple-devil/))
|
||||||
- [Becel](https://www.becel.ca/en-ca) (Becel Hat Image)
|
- [Becel](https://www.becel.ca/en-ca) (Becel Hat Image)
|
||||||
|
- [Joe Biden for President](https://joebiden.com/) (Biden Hat Image)
|
||||||
* **he-lives-in-you:**
|
* **he-lives-in-you:**
|
||||||
- [Disney](https://www.disney.com/) ([Image, Original "The Lion King" Movie](https://movies.disney.com/the-lion-king))
|
- [Disney](https://www.disney.com/) ([Image, Original "The Lion King" Movie](https://movies.disney.com/the-lion-king))
|
||||||
* **hearts:**
|
* **hearts:**
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 159 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 148 KiB |
@@ -120,6 +120,11 @@ module.exports = class HatCommand extends Command {
|
|||||||
name: 'Becel',
|
name: 'Becel',
|
||||||
url: 'https://www.becel.ca/en-ca',
|
url: 'https://www.becel.ca/en-ca',
|
||||||
reason: 'Becel Hat Image'
|
reason: 'Becel Hat Image'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Joe Biden for President',
|
||||||
|
url: 'https://joebiden.com/',
|
||||||
|
reason: 'Biden Hat Image'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
const Command = require('../../framework/Command');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = class ShrekCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'shrek',
|
||||||
|
group: 'edit-face',
|
||||||
|
memberName: 'shrek',
|
||||||
|
description: 'Draws Shrek\'s face onto the faces in an image.',
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 60
|
||||||
|
},
|
||||||
|
credit: [
|
||||||
|
{
|
||||||
|
name: 'DreamWorks',
|
||||||
|
url: 'https://www.dreamworks.com/',
|
||||||
|
reasonURL: 'https://www.dreamworks.com/movies/shrek',
|
||||||
|
reason: 'Images, Original "Shrek" Movie'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'image',
|
||||||
|
type: 'image-or-avatar'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { image }) {
|
||||||
|
const danny = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'shrek.png'));
|
||||||
|
const imgData = await request.get(image);
|
||||||
|
const faces = await this.client.detectFaces(imgData.body);
|
||||||
|
if (!faces) return msg.reply('There are no faces in this image.');
|
||||||
|
if (faces === 'size') return msg.reply('This image is too large.');
|
||||||
|
const base = await loadImage(imgData.body);
|
||||||
|
const canvas = createCanvas(base.width, base.height);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.drawImage(base, 0, 0);
|
||||||
|
for (const face of faces) {
|
||||||
|
const ratio = face.box.width / danny.width;
|
||||||
|
const height = danny.height * ratio;
|
||||||
|
ctx.drawImage(
|
||||||
|
danny,
|
||||||
|
face.box.xMin - (face.box.width * 0.2),
|
||||||
|
face.box.yMin - (height / 2.5),
|
||||||
|
face.box.width * 1.4,
|
||||||
|
height * 1.4
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'shrek.png' }] });
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user