mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-15 15:57:47 +02:00
Hearts Command
This commit is contained in:
@@ -47,7 +47,7 @@ Xiao is a Discord bot coded in JavaScript with
|
|||||||
7. Run `npm i -g pm2` to install PM2.
|
7. Run `npm i -g pm2` to install PM2.
|
||||||
8. Run `pm2 start Xiao.js --name xiao` to run the bot.
|
8. Run `pm2 start Xiao.js --name xiao` to run the bot.
|
||||||
|
|
||||||
## Commands (331)
|
## Commands (332)
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
* **eval:** Executes JavaScript code.
|
* **eval:** Executes JavaScript code.
|
||||||
@@ -330,6 +330,7 @@ Xiao is a Discord bot coded in JavaScript with
|
|||||||
* **girl-worth-fighting-for:** Draws a user's avatar as the object of Ling's affection.
|
* **girl-worth-fighting-for:** Draws a user's avatar as the object of Ling's affection.
|
||||||
* **hat:** Draws a hat over a user's avatar.
|
* **hat:** Draws a hat over a user's avatar.
|
||||||
* **he-lives-in-you:** Draws a user's avatar over Simba from The Lion King's reflection.
|
* **he-lives-in-you:** Draws a user's avatar over Simba from The Lion King's reflection.
|
||||||
|
* **hearts:** Draws hearts around a user's avatar.
|
||||||
* **i-have-the-power:** Draws a user's avatar over He-Man's face.
|
* **i-have-the-power:** Draws a user's avatar over He-Man's face.
|
||||||
* **look-at-this-photograph:** Draws a user's avatar over Nickelback's photograph.
|
* **look-at-this-photograph:** Draws a user's avatar over Nickelback's photograph.
|
||||||
* **look-what-karen-have:** Draws a user's avatar over Karen's piece of paper.
|
* **look-what-karen-have:** Draws a user's avatar over Karen's piece of paper.
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 750 KiB |
@@ -0,0 +1,46 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const path = require('path');
|
||||||
|
const { drawImageWithTint } = require('../../util/Canvas');
|
||||||
|
|
||||||
|
module.exports = class HeartsCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'hearts',
|
||||||
|
aliases: ['heart'],
|
||||||
|
group: 'avatar-edit',
|
||||||
|
memberName: 'hearts',
|
||||||
|
description: 'Draws hearts around 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', 'hearts.png'));
|
||||||
|
const { body } = await request.get(avatarURL);
|
||||||
|
const avatar = await loadImage(body);
|
||||||
|
const canvas = createCanvas(avatar.width, avatar.height);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
drawImageWithTint(ctx, avatar, 'pink', 0, 0, avatar.width, avatar.height);
|
||||||
|
ctx.drawImage(base, 0, 0, avatar.width, avatar.height);
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'hearts.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": "101.0.2",
|
"version": "101.1.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