mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
Circle Avatar Command
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
@@ -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
@@ -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": {
|
||||||
|
|||||||
Reference in New Issue
Block a user