Brazzers logo command

This commit is contained in:
Daniel Odendahl Jr
2019-02-15 21:33:11 +00:00
parent 72a35befc1
commit c251d750e0
4 changed files with 51 additions and 2 deletions
+2 -1
View File
@@ -47,7 +47,7 @@ Xiao is a Discord bot coded in JavaScript with
7. Run `npm i -g pm2` to install PM2.
8. Run `pm2 start Xiao.js --name xiao` to run the bot.
## Commands (332)
## Commands (333)
### Utility:
* **eval:** Executes JavaScript code.
@@ -280,6 +280,7 @@ Xiao is a Discord bot coded in JavaScript with
* **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.
* **brazzers:** Draws an image with the Brazzers logo in the corner.
* **circle:** Draws an image or a user's avatar as a circle.
* **color:** Sends an image of the color you choose.
* **contrast:** Draws an image or a user's avatar but with contrast.
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

+48
View File
@@ -0,0 +1,48 @@
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: 'image-edit',
memberName: 'brazzers',
description: 'Draws an image with the Brazzers logo in the corner.',
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', '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 / 4;
const height = Math.round(width / ratio);
ctx.drawImage(base, data.width - width, 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!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "101.1.2",
"version": "101.2.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {