mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 14:19:56 +02:00
Allow many more memes to support all images
This commit is contained in:
@@ -2,14 +2,15 @@ const Command = require('../../structures/Command');
|
|||||||
const { createCanvas, loadImage } = require('canvas');
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { centerImagePart } = require('../../util/Canvas');
|
||||||
|
|
||||||
module.exports = class DexterCommand extends Command {
|
module.exports = class DexterCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'dexter',
|
name: 'dexter',
|
||||||
group: 'avatar-edit',
|
group: 'image-edit',
|
||||||
memberName: 'dexter',
|
memberName: 'dexter',
|
||||||
description: 'Draws a user\'s avatar over the screen of Dexter from Pokémon.',
|
description: 'Draws an image or a user\'s avatar over the screen of Dexter from Pokémon.',
|
||||||
throttling: {
|
throttling: {
|
||||||
usages: 1,
|
usages: 1,
|
||||||
duration: 10
|
duration: 10
|
||||||
@@ -24,26 +25,26 @@ module.exports = class DexterCommand extends Command {
|
|||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'user',
|
key: 'image',
|
||||||
prompt: 'Which user would you like to edit the avatar of?',
|
prompt: 'What image would you like to edit?',
|
||||||
type: 'user',
|
type: 'image',
|
||||||
default: msg => msg.author
|
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { user }) {
|
async run(msg, { image }) {
|
||||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
|
||||||
try {
|
try {
|
||||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'dexter.png'));
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'dexter.png'));
|
||||||
const { body } = await request.get(avatarURL);
|
const { body } = await request.get(image);
|
||||||
const avatar = await loadImage(body);
|
const avatar = 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);
|
||||||
ctx.rotate(-11 * (Math.PI / 180));
|
ctx.rotate(-11 * (Math.PI / 180));
|
||||||
ctx.drawImage(avatar, 234, 274, 225, 225);
|
const { x, y, width, height } = centerImagePart(avatar, 225, 225, 234, 274);
|
||||||
|
ctx.drawImage(avatar, x, y, width, height);
|
||||||
ctx.rotate(11 * (Math.PI / 180));
|
ctx.rotate(11 * (Math.PI / 180));
|
||||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'dexter.png' }] });
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'dexter.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -2,16 +2,16 @@ const Command = require('../../structures/Command');
|
|||||||
const { createCanvas, loadImage } = require('canvas');
|
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 } = require('../../util/Canvas');
|
const { silhouette, centerImagePart } = require('../../util/Canvas');
|
||||||
|
|
||||||
module.exports = class ChallengerCommand extends Command {
|
module.exports = class ChallengerCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'challenger',
|
name: 'challenger',
|
||||||
aliases: ['challenger-approaching'],
|
aliases: ['challenger-approaching'],
|
||||||
group: 'avatar-edit',
|
group: 'meme-gen',
|
||||||
memberName: 'challenger',
|
memberName: 'challenger',
|
||||||
description: 'Draws a user\'s avatar over Super Smash Bros.\'s "Challenger Approaching" screen.',
|
description: 'Draws an image or a user\'s avatar over Smash Bros.\'s "Challenger Approaching" screen.',
|
||||||
throttling: {
|
throttling: {
|
||||||
usages: 1,
|
usages: 1,
|
||||||
duration: 10
|
duration: 10
|
||||||
@@ -33,10 +33,10 @@ module.exports = class ChallengerCommand extends Command {
|
|||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'user',
|
key: 'image',
|
||||||
prompt: 'Which user would you like to edit the avatar of?',
|
prompt: 'What image would you like to edit?',
|
||||||
type: 'user',
|
type: 'image',
|
||||||
default: msg => msg.author
|
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'silhouetted',
|
key: 'silhouetted',
|
||||||
@@ -48,16 +48,16 @@ module.exports = class ChallengerCommand extends Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { user, silhouetted }) {
|
async run(msg, { image, silhouetted }) {
|
||||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
|
||||||
try {
|
try {
|
||||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger.png'));
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger.png'));
|
||||||
const { body } = await request.get(avatarURL);
|
const { body } = await request.get(image);
|
||||||
const avatar = await loadImage(body);
|
const avatar = 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);
|
||||||
ctx.drawImage(silhouetted ? this.silhouetteImage(avatar) : avatar, 484, 98, 256, 256);
|
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' }] });
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'challenger.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
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 { createCanvas, loadImage } = require('canvas');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { centerImagePart } = require('../../util/Canvas');
|
||||||
|
|
||||||
module.exports = class GirlWorthFightingForCommand extends Command {
|
module.exports = class GirlWorthFightingForCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -10,7 +11,7 @@ module.exports = class GirlWorthFightingForCommand extends Command {
|
|||||||
aliases: ['a-girl-worth-fighting-for', 'ling'],
|
aliases: ['a-girl-worth-fighting-for', 'ling'],
|
||||||
group: 'meme-gen',
|
group: 'meme-gen',
|
||||||
memberName: 'girl-worth-fighting-for',
|
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: {
|
throttling: {
|
||||||
usages: 1,
|
usages: 1,
|
||||||
duration: 10
|
duration: 10
|
||||||
@@ -32,25 +33,25 @@ module.exports = class GirlWorthFightingForCommand extends Command {
|
|||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'user',
|
key: 'image',
|
||||||
prompt: 'Which user would you like to edit the avatar of?',
|
prompt: 'What image would you like to edit?',
|
||||||
type: 'user',
|
type: 'image',
|
||||||
default: msg => msg.author
|
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { user }) {
|
async run(msg, { image }) {
|
||||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
|
||||||
try {
|
try {
|
||||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'girl-worth-fighting-for.png'));
|
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 avatar = 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);
|
||||||
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' }] });
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'girl-worth-fighting-for.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
|||||||
+8
-9
@@ -8,9 +8,9 @@ module.exports = class LookAtThisPhotographCommand extends Command {
|
|||||||
super(client, {
|
super(client, {
|
||||||
name: 'look-at-this-photograph',
|
name: 'look-at-this-photograph',
|
||||||
aliases: ['nickelback', 'look-at-this-photo', 'photograph'],
|
aliases: ['nickelback', 'look-at-this-photo', 'photograph'],
|
||||||
group: 'avatar-edit',
|
group: 'meme-gen',
|
||||||
memberName: 'look-at-this-photograph',
|
memberName: 'look-at-this-photograph',
|
||||||
description: 'Draws a user\'s avatar over Nickelback\'s photograph.',
|
description: 'Draws an image or a user\'s avatar over Nickelback\'s photograph.',
|
||||||
throttling: {
|
throttling: {
|
||||||
usages: 1,
|
usages: 1,
|
||||||
duration: 10
|
duration: 10
|
||||||
@@ -26,20 +26,19 @@ module.exports = class LookAtThisPhotographCommand extends Command {
|
|||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'user',
|
key: 'image',
|
||||||
prompt: 'Which user would you like to edit the avatar of?',
|
prompt: 'What image would you like to edit?',
|
||||||
type: 'user',
|
type: 'image',
|
||||||
default: msg => msg.author
|
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { user }) {
|
async run(msg, { image }) {
|
||||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
|
||||||
try {
|
try {
|
||||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'look-at-this-photograph.png'));
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'look-at-this-photograph.png'));
|
||||||
const { body } = await request.get(avatarURL);
|
const { body } = await request.get(image);
|
||||||
const avatar = await loadImage(body);
|
const avatar = 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');
|
||||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
|||||||
const { createCanvas, loadImage } = require('canvas');
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { centerImagePart } = require('../../util/Canvas');
|
||||||
|
|
||||||
module.exports = class UltimateTattooCommand extends Command {
|
module.exports = class UltimateTattooCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -10,7 +11,7 @@ module.exports = class UltimateTattooCommand extends Command {
|
|||||||
aliases: ['the-ultimate-tattoo', 'tattoo'],
|
aliases: ['the-ultimate-tattoo', 'tattoo'],
|
||||||
group: 'meme-gen',
|
group: 'meme-gen',
|
||||||
memberName: 'ultimate-tattoo',
|
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: {
|
throttling: {
|
||||||
usages: 1,
|
usages: 1,
|
||||||
duration: 10
|
duration: 10
|
||||||
@@ -31,26 +32,26 @@ module.exports = class UltimateTattooCommand extends Command {
|
|||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'user',
|
key: 'image',
|
||||||
prompt: 'Which user would you like to edit the avatar of?',
|
prompt: 'What image would you like to edit?',
|
||||||
type: 'user',
|
type: 'image',
|
||||||
default: msg => msg.author
|
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { user }) {
|
async run(msg, { image }) {
|
||||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 });
|
|
||||||
try {
|
try {
|
||||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'ultimate-tattoo.png'));
|
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 avatar = 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);
|
||||||
ctx.rotate(-10 * (Math.PI / 180));
|
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));
|
ctx.rotate(10 * (Math.PI / 180));
|
||||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ultimate-tattoo.png' }] });
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ultimate-tattoo.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
|||||||
const { createCanvas, loadImage } = require('canvas');
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { centerImagePart } = require('../../util/Canvas');
|
||||||
|
|
||||||
module.exports = class WorthlessCommand extends Command {
|
module.exports = class WorthlessCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -10,7 +11,7 @@ module.exports = class WorthlessCommand extends Command {
|
|||||||
aliases: ['this-is-worthless'],
|
aliases: ['this-is-worthless'],
|
||||||
group: 'meme-gen',
|
group: 'meme-gen',
|
||||||
memberName: 'worthless',
|
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: {
|
throttling: {
|
||||||
usages: 1,
|
usages: 1,
|
||||||
duration: 10
|
duration: 10
|
||||||
@@ -26,31 +27,32 @@ module.exports = class WorthlessCommand extends Command {
|
|||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'user',
|
key: 'image',
|
||||||
prompt: 'Which user would you like to edit the avatar of?',
|
prompt: 'What image would you like to edit?',
|
||||||
type: 'user',
|
type: 'image',
|
||||||
default: msg => msg.author
|
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { user }) {
|
async run(msg, { image }) {
|
||||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
|
||||||
try {
|
try {
|
||||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'worthless.png'));
|
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 avatar = 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);
|
||||||
ctx.rotate(6 * (Math.PI / 180));
|
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.rotate(-6 * (Math.PI / 180));
|
||||||
ctx.translate(canvas.width / 2, canvas.height / 2);
|
ctx.translate(canvas.width / 2, canvas.height / 2);
|
||||||
ctx.rotate(160 * (Math.PI / 180));
|
ctx.rotate(160 * (Math.PI / 180));
|
||||||
ctx.translate(-(canvas.width / 2), -(canvas.height / 2));
|
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));
|
ctx.rotate(-160 * (Math.PI / 180));
|
||||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'worthless.png' }] });
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'worthless.png' }] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user