mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Thug Life Supports Images
This commit is contained in:
@@ -263,6 +263,7 @@ on the [home server](https://discord.gg/sbMe32W).
|
||||
* **shields-io-badge:** Creates a badge from shields.io.
|
||||
* **silhouette:** Draws a silhouette of an image or a user's avatar.
|
||||
* **sora-selfie:** Draws an image or a user's avatar behind Sora taking a selfie.
|
||||
* **thug-life:** Draws "Thug Life" over an image or a user's avatar.
|
||||
* **tint:** Draws an image or a user's avatar but tinted a specific color.
|
||||
* **to-be-continued:** Draws an image with the "To Be Continued..." arrow.
|
||||
* **vietnam-flashbacks:** Edits Vietnam flashbacks behind an image or a user's avatar.
|
||||
@@ -288,7 +289,6 @@ on the [home server](https://discord.gg/sbMe32W).
|
||||
* **the-ultimate-tattoo:** Draws a user's avatar as "The Ultimate Tattoo".
|
||||
* **this-is-beautiful:** Draws a user's avatar over Gravity Falls' "Oh, this? This is beautiful." meme.
|
||||
* **this-is-worthless:** Draws a user's avatar over Gravity Falls' "Oh, this? This is worthless." meme.
|
||||
* **thug-life:** Draws "Thug Life" over a user's avatar.
|
||||
* **triggered:** Draws a user's avatar over the "Triggered" meme.
|
||||
* **wanted:** Draws a user's avatar over a wanted poster.
|
||||
* **yu-gi-oh-token:** Draws a user's avatar over a blank Yu-Gi-Oh! Token card.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 127 KiB |
@@ -1,46 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { greyscale } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class ThugLifeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'thug-life',
|
||||
group: 'avatar-edit',
|
||||
memberName: 'thug-life',
|
||||
description: 'Draws "Thug Life" 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', 'thug-life.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);
|
||||
greyscale(ctx, 0, 0, avatar.width, avatar.height);
|
||||
ctx.drawImage(base, 0, 0, avatar.width, avatar.height);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'thug-life.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { greyscale } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class ThugLifeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'thug-life',
|
||||
group: 'image-edit',
|
||||
memberName: 'thug-life',
|
||||
description: 'Draws "Thug Life" 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: 2048 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'thug-life.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);
|
||||
greyscale(ctx, 0, 0, data.width, data.height);
|
||||
const ratio = base.width / base.height;
|
||||
const width = data.width / 2;
|
||||
const height = Math.round(width / ratio);
|
||||
ctx.drawImage(base, (data.width / 2) - (width / 2), 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: 'thug-life.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.8.1",
|
||||
"version": "91.8.2",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user