mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 22:32:52 +02:00
Allow many more memes to support all images
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { silhouette, centerImagePart } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class ChallengerCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'challenger',
|
||||
aliases: ['challenger-approaching'],
|
||||
group: 'meme-gen',
|
||||
memberName: 'challenger',
|
||||
description: 'Draws an image or a user\'s avatar over Smash Bros.\'s "Challenger Approaching" screen.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Jack The Awesomeness Gamer',
|
||||
url: 'https://www.youtube.com/channel/UCIeA23B91hAeR1UuC2VDSdQ',
|
||||
reason: 'Image',
|
||||
reasonURL: 'https://www.youtube.com/watch?v=3FebRrXg0bk'
|
||||
},
|
||||
{
|
||||
name: 'Nintendo',
|
||||
url: 'https://www.nintendo.com/',
|
||||
reason: 'Original "Super Smash Bros." Game',
|
||||
reasonURL: 'https://www.smashbros.com/en_US/index.html'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
|
||||
},
|
||||
{
|
||||
key: 'silhouetted',
|
||||
prompt: 'Should the image be silhouetted?',
|
||||
type: 'boolean',
|
||||
default: false
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image, silhouetted }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger.png'));
|
||||
const { body } = await request.get(image);
|
||||
const avatar = 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(avatar, 256, 256, 484, 98);
|
||||
ctx.drawImage(silhouetted ? this.silhouetteImage(avatar) : avatar, x, y, width, height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'challenger.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
silhouetteImage(image) {
|
||||
const canvas = createCanvas(image.width, image.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(image, 0, 0);
|
||||
silhouette(ctx, 0, 0, image.width, image.height);
|
||||
return canvas;
|
||||
}
|
||||
};
|
||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { centerImagePart } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class GirlWorthFightingForCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -10,7 +11,7 @@ module.exports = class GirlWorthFightingForCommand extends Command {
|
||||
aliases: ['a-girl-worth-fighting-for', 'ling'],
|
||||
group: 'meme-gen',
|
||||
memberName: 'girl-worth-fighting-for',
|
||||
description: 'Draws a user\'s avatar as the object of Ling\'s affection.',
|
||||
description: 'Draws an image or a user\'s avatar as the object of Ling\'s affection.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
@@ -32,25 +33,25 @@ module.exports = class GirlWorthFightingForCommand extends Command {
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'Which user would you like to edit the avatar of?',
|
||||
type: 'user',
|
||||
default: msg => msg.author
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'girl-worth-fighting-for.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await request.get(image);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.drawImage(avatar, 380, 511, 150, 150);
|
||||
const { x, y, width, height } = centerImagePart(avatar, 150, 150, 380, 511);
|
||||
ctx.drawImage(avatar, x, y, width, height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'girl-worth-fighting-for.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class LookAtThisPhotographCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'look-at-this-photograph',
|
||||
aliases: ['nickelback', 'look-at-this-photo', 'photograph'],
|
||||
group: 'meme-gen',
|
||||
memberName: 'look-at-this-photograph',
|
||||
description: 'Draws an image or a user\'s avatar over Nickelback\'s photograph.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Nickelback',
|
||||
url: 'https://www.nickelback.com/',
|
||||
reason: 'Image, Original "Photograph" Music Video',
|
||||
reasonURL: 'https://www.youtube.com/watch?v=BB0DU4DoPP4'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'look-at-this-photograph.png'));
|
||||
const { body } = await request.get(image);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.rotate(-13.5 * (Math.PI / 180));
|
||||
ctx.drawImage(avatar, 280, 218, 175, 125);
|
||||
ctx.rotate(13.5 * (Math.PI / 180));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'look-at-this-photograph.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { centerImagePart } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class UltimateTattooCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -10,7 +11,7 @@ module.exports = class UltimateTattooCommand extends Command {
|
||||
aliases: ['the-ultimate-tattoo', 'tattoo'],
|
||||
group: 'meme-gen',
|
||||
memberName: 'ultimate-tattoo',
|
||||
description: 'Draws a user\'s avatar as "The Ultimate Tattoo".',
|
||||
description: 'Draws an image or a user\'s avatar as "The Ultimate Tattoo".',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
@@ -31,26 +32,26 @@ module.exports = class UltimateTattooCommand extends Command {
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'Which user would you like to edit the avatar of?',
|
||||
type: 'user',
|
||||
default: msg => msg.author
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'ultimate-tattoo.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await request.get(image);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.rotate(-10 * (Math.PI / 180));
|
||||
ctx.drawImage(avatar, 84, 690, 300, 300);
|
||||
const { x, y, width, height } = centerImagePart(avatar, 300, 300, 84, 690);
|
||||
ctx.drawImage(avatar, x, y, width, height);
|
||||
ctx.rotate(10 * (Math.PI / 180));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ultimate-tattoo.png' }] });
|
||||
} catch (err) {
|
||||
|
||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { centerImagePart } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class WorthlessCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -10,7 +11,7 @@ module.exports = class WorthlessCommand extends Command {
|
||||
aliases: ['this-is-worthless'],
|
||||
group: 'meme-gen',
|
||||
memberName: 'worthless',
|
||||
description: 'Draws a user\'s avatar over Gravity Falls\' "Oh, this? This is worthless." meme.',
|
||||
description: 'Draws an image or a user\'s avatar over Gravity Falls\' "This is worthless." meme.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
@@ -26,31 +27,32 @@ module.exports = class WorthlessCommand extends Command {
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'Which user would you like to edit the avatar of?',
|
||||
type: 'user',
|
||||
default: msg => msg.author
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'worthless.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await request.get(image);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.rotate(6 * (Math.PI / 180));
|
||||
ctx.drawImage(avatar, 496, 183, 400, 400);
|
||||
const center1 = centerImagePart(avatar, 400, 400, 496, 183);
|
||||
ctx.drawImage(avatar, center1.x, center1.y, center1.width, center1.height);
|
||||
ctx.rotate(-6 * (Math.PI / 180));
|
||||
ctx.translate(canvas.width / 2, canvas.height / 2);
|
||||
ctx.rotate(160 * (Math.PI / 180));
|
||||
ctx.translate(-(canvas.width / 2), -(canvas.height / 2));
|
||||
ctx.drawImage(avatar, 625, 55, 75, 75);
|
||||
const center2 = centerImagePart(avatar, 75, 75, 625, 55);
|
||||
ctx.drawImage(avatar, center2.x, center2.y, center2.width, center2.height);
|
||||
ctx.rotate(-160 * (Math.PI / 180));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'worthless.png' }] });
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user