mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Pixelize and Rainbow support images
This commit is contained in:
@@ -239,7 +239,9 @@ on the [home server](https://discord.gg/sbMe32W).
|
||||
* **minecraft-skin**: Sends the Minecraft skin for a user.
|
||||
* **needs-more-jpeg**: Draws an image or a user's avatar as a low quality JPEG.
|
||||
* **osu-signature**: Creates a card based on an osu! user's stats.
|
||||
* **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 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.
|
||||
@@ -265,8 +267,6 @@ on the [home server](https://discord.gg/sbMe32W).
|
||||
* **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.
|
||||
* **pixelize**: Draws a user's avatar pixelized.
|
||||
* **rainbow**: Draws a rainbow over a user's avatar.
|
||||
* **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.
|
||||
|
||||
@@ -6,9 +6,9 @@ module.exports = class PixelizeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'pixelize',
|
||||
group: 'avatar-edit',
|
||||
group: 'image-edit',
|
||||
memberName: 'pixelize',
|
||||
description: 'Draws a user\'s avatar pixelized.',
|
||||
description: 'Draws an image or a user\'s avatar pixelized.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
@@ -16,24 +16,26 @@ module.exports = class PixelizeCommand 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|avatar',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
const avatarURL = user.displayAvatarURL({ format: 'png', size: 64 });
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await request.get(image);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(512, 512);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
ctx.drawImage(avatar, 0, 0, 512, 512);
|
||||
const width = canvas.width * 0.25;
|
||||
const height = canvas.height * 0.25;
|
||||
ctx.drawImage(avatar, 0, 0, width, height);
|
||||
ctx.drawImage(canvas, 0, 0, width, height, 0, 0, canvas.width, canvas.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'pixelize.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
@@ -8,9 +8,9 @@ module.exports = class RainbowCommand extends Command {
|
||||
super(client, {
|
||||
name: 'rainbow',
|
||||
aliases: ['gay'],
|
||||
group: 'avatar-edit',
|
||||
group: 'image-edit',
|
||||
memberName: 'rainbow',
|
||||
description: 'Draws a rainbow over a user\'s avatar.',
|
||||
description: 'Draws a rainbow over an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
@@ -18,20 +18,19 @@ module.exports = class RainbowCommand 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|avatar',
|
||||
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', 'rainbow.png'));
|
||||
const { body } = await request.get(avatarURL);
|
||||
const { body } = await request.get(image);
|
||||
const avatar = await loadImage(body);
|
||||
const canvas = createCanvas(avatar.width, avatar.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "88.1.0",
|
||||
"version": "88.1.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user