mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Approved, Rejected, and Fire support images
This commit is contained in:
@@ -231,12 +231,14 @@ on the [home server](https://discord.gg/sbMe32W).
|
||||
### Image Manipulation:
|
||||
|
||||
* **achievement:** Sends a Minecraft achievement with the text of your choice.
|
||||
* **approved:** Draws an "approved" stamp over an image or a user's avatar.
|
||||
* **be-like-bill:** Sends a "Be Like Bill" meme with the name of your choice.
|
||||
* **color:** Sends an image of the color you choose.
|
||||
* **contrast:** Draws an image or a user's avatar but with contrast.
|
||||
* **create-qr-code:** Converts text to a QR Code.
|
||||
* **demotivational-poster:** Draws an image or a user's avatar and the text you specify as a demotivational poster.
|
||||
* **distort:** Draws an image or a user's avatar but distorted.
|
||||
* **fire:** Draws a fiery border over an image or a user's avatar.
|
||||
* **frame:** Draws a frame around an image or a user's avatar.
|
||||
* **glitch:** Draws an image or a user's avatar but glitched.
|
||||
* **greyscale:** Draws an image or a user's avatar in greyscale.
|
||||
@@ -251,6 +253,7 @@ on the [home server](https://discord.gg/sbMe32W).
|
||||
* **pixelize:** Draws an image or a user's avatar pixelized.
|
||||
* **pokemon-fusion:** Fuses two Generation I Pokémon together.
|
||||
* **rainbow:** Draws a rainbow over an image or a user's avatar.
|
||||
* **rejected:** Draws a "rejected" stamp over an image or a user's avatar.
|
||||
* **robohash:** Creates a robot based on the text you provide.
|
||||
* **sepia:** Draws an image or a user's avatar in sepia.
|
||||
* **shields-io-badge:** Creates a badge from shields.io.
|
||||
@@ -261,21 +264,18 @@ on the [home server](https://discord.gg/sbMe32W).
|
||||
### Avatar Manipulation:
|
||||
|
||||
* **3000-years:** Draws a user's avatar over Pokémon's "It's been 3000 years" meme.
|
||||
* **approved:** Draws an "approved" stamp over a user's avatar.
|
||||
* **avatar-fusion:** Draws a a user's avatar over a user's avatar.
|
||||
* **bob-ross:** Draws a user's avatar over Bob Ross' canvas.
|
||||
* **challenger:** Draws a user's avatar over Super Smash Bros.'s "Challenger Approaching" screen.
|
||||
* **dexter:** Draws a user's avatar over the screen of Dexter from Pokémon.
|
||||
* **distracted-boyfriend:** Draws three user's avatars over the "Distracted Boyfriend" meme.
|
||||
* **drakeposting:** Draws two user's avatars over the "Drakeposting" meme.
|
||||
* **fire:** Draws a fiery border over a user's avatar.
|
||||
* **food-broke:** Draws a user's avatar over the "Food Broke" meme.
|
||||
* **hat:** Draws a hat over a user's avatar.
|
||||
* **he-lives-in-you:** Draws a user's avatar over Simba from The Lion King's reflection.
|
||||
* **i-have-the-power:** Draws a user's avatar over He-Man's face.
|
||||
* **look-at-this-photograph:** Draws a user's avatar over Nickelback's photograph.
|
||||
* **look-what-karen-have:** Draws a user's avatar over Karen's piece of paper.
|
||||
* **rejected:** Draws a "rejected" stamp over a user's avatar.
|
||||
* **rip:** Draws a user's avatar over a gravestone.
|
||||
* **steam-card:** Draws a user's avatar on a Steam Trading Card.
|
||||
* **steam-now-playing:** Draws a user's avatar and the game of your choice over a Steam "now playing" notification.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 116 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 517 KiB After Width: | Height: | Size: 270 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 389 KiB After Width: | Height: | Size: 89 KiB |
@@ -1,45 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class ApprovedCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'approved',
|
||||
aliases: ['approve'],
|
||||
group: 'avatar-edit',
|
||||
memberName: 'approved',
|
||||
description: 'Draws an "approved" stamp over a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'Which user would you like to edit the avatar of?',
|
||||
type: 'user',
|
||||
default: msg => msg.author
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'approved.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(avatar, 0, 0);
|
||||
ctx.drawImage(base, 0, 0, avatar.width, avatar.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'approved.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,45 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class RejctedCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'rejected',
|
||||
aliases: ['reject'],
|
||||
group: 'avatar-edit',
|
||||
memberName: 'rejected',
|
||||
description: 'Draws a "rejected" stamp over a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'Which user would you like to edit the avatar of?',
|
||||
type: 'user',
|
||||
default: msg => msg.author
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'rejected.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(avatar, 0, 0);
|
||||
ctx.drawImage(base, 0, 0, avatar.width, avatar.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'rejected.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class ApprovedCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'approved',
|
||||
aliases: ['approve'],
|
||||
group: 'image-edit',
|
||||
memberName: 'approved',
|
||||
description: 'Draws an "approved" stamp 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', '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 dataRatio = data.width / data.height;
|
||||
const baseRatio = base.width / base.height;
|
||||
let width = data.width;
|
||||
let height = data.height;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
if (baseRatio < dataRatio) {
|
||||
height = data.height;
|
||||
width = base.width * (height / base.height);
|
||||
x = (data.width - width) / 2;
|
||||
y = 0;
|
||||
} else if (baseRatio > dataRatio) {
|
||||
width = data.width;
|
||||
height = base.height * (width / base.width);
|
||||
x = 0;
|
||||
y = (data.height - height) / 2;
|
||||
}
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -36,7 +36,7 @@ module.exports = class DemotivationalPosterCommand extends Command {
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 1024 })
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -9,9 +9,9 @@ module.exports = class FireCommand extends Command {
|
||||
super(client, {
|
||||
name: 'fire',
|
||||
aliases: ['flame', 'hell'],
|
||||
group: 'avatar-edit',
|
||||
group: 'image-edit',
|
||||
memberName: 'fire',
|
||||
description: 'Draws a fiery border over a user\'s avatar.',
|
||||
description: 'Draws a fiery border over an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
@@ -19,26 +19,27 @@ module.exports = class FireCommand extends Command {
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
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', 'fire.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
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, avatar, '#fc671e', 0, 0, avatar.width, avatar.height);
|
||||
ctx.drawImage(base, 0, 0, avatar.width, avatar.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'fire.png' }] });
|
||||
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,63 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class RejctedCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'rejected',
|
||||
aliases: ['reject'],
|
||||
group: 'image-edit',
|
||||
memberName: 'rejected',
|
||||
description: 'Draws a "rejected" stamp 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', '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 dataRatio = data.width / data.height;
|
||||
const baseRatio = base.width / base.height;
|
||||
let width = data.width;
|
||||
let height = data.height;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
if (baseRatio < dataRatio) {
|
||||
height = data.height;
|
||||
width = base.width * (height / base.height);
|
||||
x = (data.width - width) / 2;
|
||||
y = 0;
|
||||
} else if (baseRatio > dataRatio) {
|
||||
width = data.width;
|
||||
height = base.height * (width / base.width);
|
||||
x = 0;
|
||||
y = (data.height - height) / 2;
|
||||
}
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "91.2.2",
|
||||
"version": "91.2.3",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user