mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 00:07:36 +02:00
More uniform group names
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const path = require('path');
|
||||
const { shortenText } = require('../../util/Canvas');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Minecraftia.ttf'), { family: 'Minecraftia' });
|
||||
|
||||
module.exports = class AchievementCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'achievement',
|
||||
aliases: ['minecraft-achievement'],
|
||||
group: 'edit-image',
|
||||
memberName: 'achievement',
|
||||
description: 'Sends a Minecraft achievement with the text of your choice.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Mojang',
|
||||
url: 'https://www.mojang.com/',
|
||||
reason: 'Original "Minecraft" Game',
|
||||
reasonURL: 'https://www.minecraft.net/en-us/'
|
||||
},
|
||||
{
|
||||
name: 'Minecraft Achievement Generator',
|
||||
url: 'https://www.minecraftskinstealer.com/achievement/',
|
||||
reason: 'Image'
|
||||
},
|
||||
{
|
||||
name: 'Andrew Tyler',
|
||||
url: 'https://www.dafont.com/andrew-tyler.d2526',
|
||||
reason: 'Minecraftia Font',
|
||||
reasonURL: 'https://www.dafont.com/minecraftia.font'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What should the text of the achievement be?',
|
||||
type: 'string',
|
||||
max: 50
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { text }) {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'achievement.png'));
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.font = '17px Minecraftia';
|
||||
ctx.fillStyle = '#ffff00';
|
||||
ctx.fillText('Achievement Get!', 60, 40);
|
||||
ctx.fillStyle = '#ffffff';
|
||||
ctx.fillText(shortenText(ctx, text, 230), 60, 60);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'achievement.png' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class AdorableCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'adorable',
|
||||
aliases: ['adorable-avatar'],
|
||||
group: 'edit-image',
|
||||
memberName: 'adorable',
|
||||
description: 'Creates an adorable avatar based on the text you provide.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Adorable Avatars',
|
||||
url: 'http://avatars.adorable.io/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What text should be used for generation?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://api.adorable.io/avatars/285/${text}.png`);
|
||||
return msg.say({ files: [{ attachment: body, name: 'adorable.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { list } = require('../../util/Util');
|
||||
const products = require('../../assets/json/apple-engraving');
|
||||
|
||||
module.exports = class AppleEngravingCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'apple-engraving',
|
||||
aliases: ['apple-engrave', 'apple-e', 'a-engrave', 'a-engraving'],
|
||||
group: 'edit-image',
|
||||
memberName: 'apple-engraving',
|
||||
description: 'Engraves the text of your choice onto an Apple product.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Apple',
|
||||
url: 'https://www.apple.com/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'product',
|
||||
prompt: `What product do you want to engrave? Either ${list(Object.keys(products), 'or')}.`,
|
||||
type: 'string',
|
||||
oneOf: Object.keys(products),
|
||||
parse: product => product.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What text do you want to engrave?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { product, text }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://www.apple.com/shop/preview/engrave/${products[product]}/A`)
|
||||
.query({
|
||||
th: text,
|
||||
s: 2,
|
||||
f: 'font1'
|
||||
});
|
||||
return msg.channel.send({ files: [{ attachment: body, name: 'apple-engraving.jpg' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { centerImage } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class ApprovedCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'approved',
|
||||
aliases: ['approve'],
|
||||
group: 'edit-image',
|
||||
memberName: 'approved',
|
||||
description: 'Draws an "approved" stamp over an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Redeeming God',
|
||||
url: 'https://redeeminggod.com/',
|
||||
reason: 'Image',
|
||||
reasonURL: 'https://redeeminggod.com/courses/gospel-dictionary/lessons/gospel-dictionary-approved/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'approved.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
const { x, y, width, height } = centerImage(base, data);
|
||||
ctx.drawImage(base, x, y, width, height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'approved.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,79 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const path = require('path');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Konosuba.ttf'), { family: 'Konosuba' });
|
||||
|
||||
module.exports = class AxisCultSignUpCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'axis-cult-sign-up',
|
||||
aliases: ['axis-sign-up'],
|
||||
group: 'edit-image',
|
||||
memberName: 'axis-cult-sign-up',
|
||||
description: 'Sends an Axis Cult Sign-Up sheet for you. Join today!',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'cheesecakejedi',
|
||||
url: 'https://imgur.com/user/cheesecakejedi',
|
||||
reason: 'Image',
|
||||
reasonURL: 'https://imgur.com/gallery/quQTD'
|
||||
},
|
||||
{
|
||||
name: 'hbl917070',
|
||||
url: 'https://github.com/hbl917070',
|
||||
reason: 'Font',
|
||||
reasonURL: 'https://github.com/hbl917070/Konosuba-text'
|
||||
},
|
||||
{
|
||||
name: 'KONOSUBA -God\'s blessing on this wonderful world!',
|
||||
url: 'http://konosuba.com/',
|
||||
reason: 'Original Anime'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'gender',
|
||||
prompt: 'What is your gender?',
|
||||
type: 'string',
|
||||
oneOf: ['male', 'female']
|
||||
},
|
||||
{
|
||||
key: 'age',
|
||||
prompt: 'How old are you?',
|
||||
type: 'integer',
|
||||
min: 1,
|
||||
max: 10000
|
||||
},
|
||||
{
|
||||
key: 'profession',
|
||||
prompt: 'What is your profession?',
|
||||
type: 'string',
|
||||
max: 15
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { gender, age, profession }) {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'axis-cult-sign-up.jpg'));
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.font = '96px Konosuba';
|
||||
ctx.fillText(msg.author.username, 960, 1558);
|
||||
ctx.fillText(gender, 960, 1752);
|
||||
ctx.fillText(age, 1700, 1752);
|
||||
ctx.fillText('XXX-XXX-XXXX', 960, 1960);
|
||||
ctx.fillText(profession, 960, 2169);
|
||||
ctx.fillText('Xiao', 960, 2370);
|
||||
ctx.font = '123px Konosuba';
|
||||
ctx.fillText('ERIS PADS\nHER CHEST!', 1037, 2874);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer('image/jpeg'), name: 'axis-cult-sign-up.jpg' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class BrazzersCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'brazzers',
|
||||
group: 'edit-image',
|
||||
memberName: 'brazzers',
|
||||
description: 'Draws an image with the Brazzers logo in the corner.',
|
||||
nsfw: true,
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Brazzers',
|
||||
url: 'https://www.brazzers.com/',
|
||||
reason: 'Logo'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'brazzers.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
const ratio = base.width / base.height;
|
||||
const width = data.width / 3;
|
||||
const height = Math.round(width / ratio);
|
||||
ctx.drawImage(base, 0, data.height - height, width, height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'brazzers.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class CircleCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'circle',
|
||||
aliases: ['preview-avatar', 'preview-ava'],
|
||||
group: 'edit-image',
|
||||
memberName: 'circle',
|
||||
description: 'Draws an image or a user\'s avatar as a circle.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'Which image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const dimensions = data.width <= data.height ? data.width : data.height;
|
||||
const canvas = createCanvas(dimensions, dimensions);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.beginPath();
|
||||
ctx.arc(canvas.width / 2, canvas.height / 2, canvas.height / 2, 0, Math.PI * 2);
|
||||
ctx.closePath();
|
||||
ctx.clip();
|
||||
ctx.drawImage(data, (canvas.width / 2) - (data.width / 2), (canvas.height / 2) - (data.height / 2));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'circle.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas } = require('canvas');
|
||||
|
||||
module.exports = class ColorCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'color',
|
||||
aliases: ['colour'],
|
||||
group: 'edit-image',
|
||||
memberName: 'color',
|
||||
description: 'Sends an image of the color you choose.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'color',
|
||||
prompt: 'What color do you want to view? This can be #colorcode or a name.',
|
||||
type: 'string',
|
||||
parse: color => color.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { color }) {
|
||||
const canvas = createCanvas(250, 250);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillRect(0, 0, 250, 250);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'color.png' }] });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { contrast } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class ContrastCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'contrast',
|
||||
group: 'edit-image',
|
||||
memberName: 'contrast',
|
||||
description: 'Draws an image or a user\'s avatar but with contrast.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
contrast(ctx, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'contrast.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class CreateQRCodeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'create-qr-code',
|
||||
aliases: ['create-qr'],
|
||||
group: 'edit-image',
|
||||
memberName: 'create-qr-code',
|
||||
description: 'Converts text to a QR Code.',
|
||||
credit: [
|
||||
{
|
||||
name: 'goQR.me',
|
||||
url: 'http://goqr.me/',
|
||||
reason: 'QR code API',
|
||||
reasonURL: 'http://goqr.me/api/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to convert to a QR Code?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.qrserver.com/v1/create-qr-code/')
|
||||
.query({ data: text });
|
||||
return msg.say({ files: [{ attachment: body, name: 'qr-code.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');
|
||||
const { centerImagePart } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class DexterCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'dexter',
|
||||
group: 'edit-image',
|
||||
memberName: 'dexter',
|
||||
description: 'Draws an image or a user\'s avatar over the screen of Dexter from Pokémon.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Pokémon',
|
||||
url: 'https://www.pokemon.com/us/',
|
||||
reason: 'Image, Original Anime'
|
||||
}
|
||||
],
|
||||
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', 'dexter.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(-11 * (Math.PI / 180));
|
||||
const { x, y, width, height } = centerImagePart(avatar, 225, 225, 234, 274);
|
||||
ctx.drawImage(avatar, x, y, width, height);
|
||||
ctx.rotate(11 * (Math.PI / 180));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'dexter.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { distort } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class DistortCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'distort',
|
||||
group: 'edit-image',
|
||||
memberName: 'distort',
|
||||
description: 'Draws an image or a user\'s avatar but distorted.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'level',
|
||||
prompt: 'What level of distortion would you like to use?',
|
||||
type: 'integer'
|
||||
},
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { level, image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
distort(ctx, level, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'distort.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { drawImageWithTint } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class FireCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'fire',
|
||||
aliases: ['hell'],
|
||||
group: 'edit-image',
|
||||
memberName: 'fire',
|
||||
description: 'Draws a fiery border over an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'susi1959',
|
||||
url: 'https://en.picmix.com/profile/susi1959',
|
||||
reason: 'Image',
|
||||
reasonURL: 'https://en.picmix.com/stamp/FIRE-FRAME-ORANGE-cadre-feu-orange-360274'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'fire.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
drawImageWithTint(ctx, data, '#fc671e', 0, 0, data.width, data.height);
|
||||
ctx.drawImage(base, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'fire.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 FrameCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'frame',
|
||||
aliases: ['picture-frame', 'photo-frame'],
|
||||
group: 'edit-image',
|
||||
memberName: 'frame',
|
||||
description: 'Draws a frame around an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'www.aljanh.net',
|
||||
url: 'http://www.aljanh.net/',
|
||||
reason: 'Image',
|
||||
reasonURL: 'http://www.aljanh.net/frame-wallpapers/1508614706.html'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'frame.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
ctx.drawImage(base, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'frame.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { distort } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class GlitchCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'glitch',
|
||||
group: 'edit-image',
|
||||
memberName: 'glitch',
|
||||
description: 'Draws an image or a user\'s avatar but glitched.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
distort(ctx, 20, 0, 0, data.width, data.height, 5);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'glitch.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { greyscale } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class GreyscaleCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'greyscale',
|
||||
aliases: ['grayscale'],
|
||||
group: 'edit-image',
|
||||
memberName: 'greyscale',
|
||||
description: 'Draws an image or a user\'s avatar in greyscale.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
greyscale(ctx, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'greyscale.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 IfunnyCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'ifunny',
|
||||
group: 'edit-image',
|
||||
memberName: 'ifunny',
|
||||
description: 'Draws an image with the iFunny logo.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'iFunny',
|
||||
url: 'https://ifunny.co/',
|
||||
reason: 'Logo'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'ifunny.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
ctx.fillStyle = '#181619';
|
||||
ctx.fillRect(0, canvas.height - base.height, canvas.width, base.height);
|
||||
ctx.drawImage(base, canvas.width - base.width, canvas.height - base.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'ifunny.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { invert } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class InvertCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'invert',
|
||||
group: 'edit-image',
|
||||
memberName: 'invert',
|
||||
description: 'Draws an image or a user\'s avatar but inverted.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
invert(ctx, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'invert.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 request = require('node-superfetch');
|
||||
const { list } = require('../../util/Util');
|
||||
const types = ['face', 'front', 'frontfull', 'head', 'bust', 'full', 'skin'];
|
||||
|
||||
module.exports = class MinecraftSkinCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'minecraft-skin',
|
||||
group: 'edit-image',
|
||||
memberName: 'minecraft-skin',
|
||||
description: 'Sends the Minecraft skin for a user.',
|
||||
details: `**Types:** ${types.join(', ')}`,
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Mojang',
|
||||
url: 'https://www.mojang.com/',
|
||||
reason: 'API, Original "Minecraft" Game',
|
||||
reasonURL: 'https://wiki.vg/Mojang_API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'What user would you like to get the skin of?',
|
||||
type: 'string',
|
||||
parse: user => encodeURIComponent(user)
|
||||
},
|
||||
{
|
||||
key: 'type',
|
||||
prompt: `What type should the skin be rendered in? Either ${list(types, 'or')}.`,
|
||||
type: 'string',
|
||||
default: 'full',
|
||||
validate: type => {
|
||||
if (types.includes(type.toLowerCase())) return true;
|
||||
return `Invalid type, please enter either ${list(types, 'or')}.`;
|
||||
},
|
||||
parse: type => type.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user, type }) {
|
||||
try {
|
||||
const search = await request.get(`https://api.mojang.com/users/profiles/minecraft/${user}`);
|
||||
if (search.status === 204) return msg.say('Could not find any results.');
|
||||
return msg.say({ files: [`https://visage.surgeplay.com/${type}/512/${search.body.id}.png`] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class NeedsMoreJpegCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'needs-more-jpeg',
|
||||
aliases: ['jpeg', 'jpegify'],
|
||||
group: 'edit-image',
|
||||
memberName: 'needs-more-jpeg',
|
||||
description: 'Draws an image or a user\'s avatar as a low quality JPEG.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
},
|
||||
{
|
||||
key: 'quality',
|
||||
prompt: 'What quality should the resulting image use?',
|
||||
type: 'float',
|
||||
default: 0.5,
|
||||
min: 0.01,
|
||||
max: 10
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image, quality }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
const attachment = canvas.toBuffer('image/jpeg', { quality: quality / 10 });
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'needs-more-jpeg.jpeg' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = class NewspaperCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'newspaper',
|
||||
group: 'edit-image',
|
||||
memberName: 'newspaper',
|
||||
description: 'Creates a fake newspaper with the headline and body of your choice.',
|
||||
credit: [
|
||||
{
|
||||
name: 'The Newspaper Clipping Generator',
|
||||
url: 'https://www.fodey.com/generators/newspaper/snippet.asp',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'headline',
|
||||
prompt: 'What do you want the headline to be?',
|
||||
type: 'string',
|
||||
max: 20
|
||||
},
|
||||
{
|
||||
key: 'body',
|
||||
prompt: 'What should the body of the article be?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { headline, body }) {
|
||||
try {
|
||||
const { text } = await request
|
||||
.post('https://www.fodey.com/generators/newspaper/snippet.asp')
|
||||
.attach('name', 'The Daily Whatever')
|
||||
.attach('date', moment().format('dddd, MMMM D, YYYY'))
|
||||
.attach('headline', headline)
|
||||
.attach('text', body);
|
||||
const newspaperURL = text.match(/<img src="(https:\/\/r[0-9]+\.fodey\.com\/[0-9]+\/.+\.jpg)"/i)[1];
|
||||
return msg.channel.send({ files: [newspaperURL] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class PixelizeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'pixelize',
|
||||
aliases: ['pixel'],
|
||||
group: 'edit-image',
|
||||
memberName: 'pixelize',
|
||||
description: 'Draws an image or a user\'s avatar pixelized.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
const width = canvas.width * 0.15;
|
||||
const height = canvas.height * 0.15;
|
||||
ctx.drawImage(data, 0, 0, width, height);
|
||||
ctx.drawImage(canvas, 0, 0, width, height, 0, 0, canvas.width, canvas.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'pixelize.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const pokemon = require('../../assets/json/pokemon-fusion');
|
||||
const { firstUpperCase } = require('../../util/Util');
|
||||
const pokeKeys = Object.keys(pokemon);
|
||||
|
||||
module.exports = class PokemonFusionCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'pokemon-fusion',
|
||||
aliases: ['poke-fusion', 'poke-fuse', 'pokémon-fusion', 'poké-fusion', 'poké-fuse'],
|
||||
group: 'edit-image',
|
||||
memberName: 'pokemon-fusion',
|
||||
description: 'Fuses two Generation I Pokémon together.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Pokémon',
|
||||
url: 'https://www.pokemon.com/us/',
|
||||
reason: 'Original Game'
|
||||
},
|
||||
{
|
||||
name: 'Pokemon Fusion',
|
||||
url: 'https://pokemon.alexonsager.net/',
|
||||
reason: 'Images'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'body',
|
||||
prompt: 'What Pokémon should be fused as the body?',
|
||||
type: 'string',
|
||||
default: () => pokeKeys[Math.floor(Math.random() * pokeKeys.length)],
|
||||
validate: body => {
|
||||
if (pokemon[body.toLowerCase()]) return true;
|
||||
return 'Invalid body, only Pokémon from Generation I may be used.';
|
||||
},
|
||||
parse: body => body.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'palette',
|
||||
prompt: 'What Pokémon should be fused as the palette?',
|
||||
type: 'string',
|
||||
default: () => pokeKeys[Math.floor(Math.random() * pokeKeys.length)],
|
||||
validate: palette => {
|
||||
if (pokemon[palette.toLowerCase()]) return true;
|
||||
return 'Invalid palette, only Pokémon from Generation I may be used.';
|
||||
},
|
||||
parse: palette => palette.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { body, palette }) {
|
||||
const prefix = body.slice(0, Math.round(body.length / 2));
|
||||
const suffix = palette.slice(Math.round(palette.length / 2));
|
||||
return msg.say(firstUpperCase(`${prefix}${suffix}`), {
|
||||
files: [`http://images.alexonsager.net/pokemon/fused/${pokemon[body]}/${pokemon[body]}.${pokemon[palette]}.png`]
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class RainbowCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'rainbow',
|
||||
aliases: ['gay'],
|
||||
group: 'edit-image',
|
||||
memberName: 'rainbow',
|
||||
description: 'Draws a rainbow over an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'rainbow.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
ctx.drawImage(base, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'rainbow.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { centerImage } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class RejctedCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'rejected',
|
||||
aliases: ['reject'],
|
||||
group: 'edit-image',
|
||||
memberName: 'rejected',
|
||||
description: 'Draws a "rejected" stamp over an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Clipart Library',
|
||||
url: 'http://clipart-library.com/',
|
||||
reason: 'Image',
|
||||
reasonURL: 'http://clipart-library.com/clipart/Rejected-Stamp-Transparent.htm'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'rejected.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
const { x, y, width, height } = centerImage(base, data);
|
||||
ctx.drawImage(base, x, y, width, height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'rejected.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class RobohashCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'robohash',
|
||||
group: 'edit-image',
|
||||
memberName: 'robohash',
|
||||
description: 'Creates a robot based on the text you provide.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'RoboHash',
|
||||
url: 'https://robohash.org/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What text should be used for generation?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://robohash.org/${text}`);
|
||||
return msg.say({ files: [{ attachment: body, name: 'robohash.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { sepia } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class SepiaCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'sepia',
|
||||
group: 'edit-image',
|
||||
memberName: 'sepia',
|
||||
description: 'Draws an image or a user\'s avatar in sepia.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
sepia(ctx, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'sepia.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class ShieldsIoBadgeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'shields-io-badge',
|
||||
aliases: ['shields-io'],
|
||||
group: 'edit-image',
|
||||
memberName: 'shields-io-badge',
|
||||
description: 'Creates a badge from shields.io.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Shields.io',
|
||||
url: 'https://shields.io/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'subject',
|
||||
prompt: 'What is the subject of the badge?',
|
||||
type: 'string',
|
||||
parse: subject => encodeURIComponent(subject.replace(/-/g, '--').replace(/_/g, '__'))
|
||||
},
|
||||
{
|
||||
key: 'status',
|
||||
prompt: 'What is the status of the badge?',
|
||||
type: 'string',
|
||||
parse: status => encodeURIComponent(status.replace(/-/g, '--').replace(/_/g, '__'))
|
||||
},
|
||||
{
|
||||
key: 'color',
|
||||
prompt: 'What is the color of the badge?',
|
||||
type: 'string',
|
||||
default: 'brightgreen'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { subject, status, color }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://img.shields.io/badge/${subject}-${status}-${color}.png`);
|
||||
return msg.say({ files: [{ attachment: body, name: 'badge.png' }] });
|
||||
} catch (err) {
|
||||
if (err.status === 404) return msg.reply('Could not create the badge...');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { silhouette } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class SilhouetteCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'silhouette',
|
||||
group: 'edit-image',
|
||||
memberName: 'silhouette',
|
||||
description: 'Draws a silhouette of an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
silhouette(ctx, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'silhouette.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class SquareCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'square',
|
||||
group: 'edit-image',
|
||||
memberName: 'square',
|
||||
description: 'Draws an image or a user\'s avatar as a square.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'Which image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const dimensions = data.width <= data.height ? data.width : data.height;
|
||||
const canvas = createCanvas(dimensions, dimensions);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, (canvas.width / 2) - (data.width / 2), (canvas.height / 2) - (data.height / 2));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'square.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const { drawImageWithTint } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class TintCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'tint',
|
||||
group: 'edit-image',
|
||||
memberName: 'tint',
|
||||
description: 'Draws an image or a user\'s avatar but tinted a specific color.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'color',
|
||||
prompt: 'What color do you want to use? This can be #colorcode or a name.',
|
||||
type: 'string',
|
||||
parse: color => color.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { color, image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
drawImageWithTint(ctx, data, color, 0, 0, data.width, data.height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'tint.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user