mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Sip 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 (334)
|
## Commands (335)
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
* **eval:** Executes JavaScript code.
|
* **eval:** Executes JavaScript code.
|
||||||
@@ -337,6 +337,7 @@ Xiao is a Discord bot coded in JavaScript with
|
|||||||
* **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.
|
||||||
* **rip:** Draws a user's avatar over a gravestone.
|
* **rip:** Draws a user's avatar over a gravestone.
|
||||||
|
* **sip:** Draws a user's avatar sipping tea.
|
||||||
* **steam-card:** Draws a user's avatar on a Steam Trading Card.
|
* **steam-card:** Draws a user's avatar on a Steam Trading Card.
|
||||||
* **steam-now-playing:** Draws a user's avatar and the game of your choice over a Steam "now playing" notification.
|
* **steam-now-playing:** Draws a user's avatar and the game of your choice over a Steam "now playing" notification.
|
||||||
* **triggered:** Draws a user's avatar over the "Triggered" meme.
|
* **triggered:** Draws a user's avatar over the "Triggered" meme.
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
@@ -0,0 +1,59 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = class SipCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'sip',
|
||||||
|
aliases: ['tea'],
|
||||||
|
group: 'avatar-edit',
|
||||||
|
memberName: 'sip',
|
||||||
|
description: 'Draws a user\'s avatar sipping tea.',
|
||||||
|
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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'direction',
|
||||||
|
prompt: 'What direction should the avatar face?',
|
||||||
|
type: 'string',
|
||||||
|
oneOf: ['left', 'right'],
|
||||||
|
default: 'left',
|
||||||
|
parse: direction => direction.toLowerCase()
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { user, direction }) {
|
||||||
|
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||||
|
try {
|
||||||
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'sip.png'));
|
||||||
|
const { body } = await request.get(avatarURL);
|
||||||
|
const avatar = await loadImage(body);
|
||||||
|
const canvas = createCanvas(base.width, base.height);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.fillRect(0, 0, base.width, base.height);
|
||||||
|
if (direction === 'right') {
|
||||||
|
ctx.translate(base.width, 0);
|
||||||
|
ctx.scale(-1, 1);
|
||||||
|
}
|
||||||
|
ctx.drawImage(avatar, 0, 0, 512, 512);
|
||||||
|
if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||||
|
ctx.drawImage(base, 0, 0);
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'sip.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.3.0",
|
"version": "101.4.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