mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Police Tape Command
This commit is contained in:
@@ -132,7 +132,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 390
|
||||
Total: 391
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -429,6 +429,7 @@ Total: 390
|
||||
* **newspaper:** Creates a fake newspaper with the headline and body of your choice.
|
||||
* **pixelize:** Draws an image or a user's avatar pixelized.
|
||||
* **pokemon-fusion:** Fuses two Generation I Pokémon together.
|
||||
* **police-tape:** Draws police tape over an image or a user's avatar.
|
||||
* **rainbow:** Draws a rainbow over an image or a user's avatar.
|
||||
* **rejected:** Draws a "rejected" stamp over an image or a user's avatar.
|
||||
* **robohash:** Creates a robot based on the text you provide.
|
||||
@@ -962,6 +963,8 @@ here.
|
||||
- [Perspective API](https://www.perspectiveapi.com/#/)
|
||||
* severe-toxicity (API)
|
||||
* toxicity (API)
|
||||
- [PNG Arts](https://www.pngarts.com/)
|
||||
* police-tape ([Image](https://www.pngarts.com/explore/94078))
|
||||
- [pngimg.com](https://pngimg.com/)
|
||||
* thug-life ([Image](http://pngimg.com/download/58231))
|
||||
- [Platinum Designz](http://store.platinumdesignz.com/)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 MiB |
@@ -0,0 +1,56 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { centerImage } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class PoliceTapeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'police-tape',
|
||||
aliases: ['caution-tape', 'caution'],
|
||||
group: 'edit-image',
|
||||
memberName: 'police tape',
|
||||
description: 'Draws police tape over an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'PNG Arts',
|
||||
url: 'https://www.pngarts.com/',
|
||||
reason: 'Image',
|
||||
reasonURL: 'https://www.pngarts.com/explore/94078'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'police-tape.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
const { x, y, width, height } = centerImage(base, data);
|
||||
ctx.drawImage(base, x, y, width, height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'police-tape.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "113.4.0",
|
||||
"version": "113.5.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user