Circle Avatar Command

This commit is contained in:
Daniel Odendahl Jr
2018-09-17 22:48:38 +00:00
parent 382cea66cc
commit 8ff7a61060
3 changed files with 49 additions and 2 deletions
+2 -1
View File
@@ -15,7 +15,7 @@ Xiao is a Discord bot coded in JavaScript with
The bot is no longer available for invite. You can self-host the bot, or use her The bot is no longer available for invite. You can self-host the bot, or use her
on the [home server](https://discord.gg/sbMe32W). on the [home server](https://discord.gg/sbMe32W).
## Commands (310) ## Commands (311)
### Utility: ### Utility:
* **eval:** Executes JavaScript code. * **eval:** Executes JavaScript code.
@@ -269,6 +269,7 @@ on the [home server](https://discord.gg/sbMe32W).
* **avatar-fusion:** Draws a a user's avatar 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. * **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. * **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. * **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. * **distracted-boyfriend:** Draws three user's avatars over the "Distracted Boyfriend" meme.
* **drakeposting:** Draws two user's avatars over the "Drakeposting" meme. * **drakeposting:** Draws two user's avatars over the "Drakeposting" meme.
+46
View File
@@ -0,0 +1,46 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage } = require('canvas');
const request = require('node-superfetch');
module.exports = class CircleCommand extends Command {
constructor(client) {
super(client, {
name: 'circle',
aliases: ['circle-avatar', 'circle-ava'],
group: 'avatar-edit',
memberName: 'circle',
description: 'Draws a user\'s avatar as a circle.',
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 { body } = await request.get(avatarURL);
const avatar = await loadImage(body);
const canvas = createCanvas(avatar.width, avatar.height);
const ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.arc(avatar.width / 2, avatar.height / 2, avatar.height / 2, 0, Math.PI * 2);
ctx.closePath();
ctx.clip();
ctx.drawImage(avatar, 0, 0);
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", "name": "xiao",
"version": "91.4.0", "version": "91.5.0",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"scripts": { "scripts": {