Circle accepts images

This commit is contained in:
Daniel Odendahl Jr
2018-09-19 14:01:42 +00:00
parent 007cd18dea
commit 6047e1dba1
3 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -235,6 +235,7 @@ on the [home server](https://discord.gg/sbMe32W).
* **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.
* **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.
* **create-qr-code:** Converts text to a QR Code.
@@ -270,7 +271,6 @@ on the [home server](https://discord.gg/sbMe32W).
* **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.
* **circle:** Draws a user's avatar as a circle.
* **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.
@@ -6,10 +6,10 @@ module.exports = class CircleCommand extends Command {
constructor(client) {
super(client, {
name: 'circle',
aliases: ['circle-avatar', 'circle-ava'],
group: 'avatar-edit',
aliases: ['circle-avatar', 'circle-ava', 'circle-image', 'circle-img'],
group: 'image-edit',
memberName: 'circle',
description: 'Draws a user\'s avatar as a circle.',
description: 'Draws an image or a user\'s avatar as a circle.',
throttling: {
usages: 1,
duration: 10
@@ -17,27 +17,27 @@ module.exports = class CircleCommand 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: 'Which 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 { 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 dimensions = data.width <= data.height ? data.width : data.height;
const canvas = createCanvas(dimensions, dimensions);
const ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.arc(avatar.width / 2, avatar.height / 2, avatar.height / 2, 0, Math.PI * 2);
ctx.arc(canvas.width / 2, canvas.height / 2, canvas.height / 2, 0, Math.PI * 2);
ctx.closePath();
ctx.clip();
ctx.drawImage(avatar, 0, 0);
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!`);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "91.6.0",
"version": "91.6.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {