mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 21:40:51 +02:00
Gru's Plan 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 (308)
|
## Commands (309)
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
* **eval:** Executes JavaScript code.
|
* **eval:** Executes JavaScript code.
|
||||||
@@ -242,6 +242,7 @@ on the [home server](https://discord.gg/sbMe32W).
|
|||||||
* **frame:** Draws a frame around an image or a user's avatar.
|
* **frame:** Draws a frame around an image or a user's avatar.
|
||||||
* **glitch:** Draws an image or a user's avatar but glitched.
|
* **glitch:** Draws an image or a user's avatar but glitched.
|
||||||
* **greyscale:** Draws an image or a user's avatar in greyscale.
|
* **greyscale:** Draws an image or a user's avatar in greyscale.
|
||||||
|
* **gru-plan:** Sends a Gru's Plan meme with steps of your choice.
|
||||||
* **ifunny:** Draws an image with the iFunny logo.
|
* **ifunny:** Draws an image with the iFunny logo.
|
||||||
* **illegal:** Makes President Trump make your text illegal.
|
* **illegal:** Makes President Trump make your text illegal.
|
||||||
* **invert:** Draws an image or a user's avatar but inverted.
|
* **invert:** Draws an image or a user's avatar but inverted.
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 686 KiB |
@@ -0,0 +1,70 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||||
|
const path = require('path');
|
||||||
|
const { wrapText } = require('../../util/Canvas');
|
||||||
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
||||||
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
|
||||||
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
|
||||||
|
const coord = [[443, 139], [1200, 143], [443, 637], [1200, 637]];
|
||||||
|
|
||||||
|
module.exports = class GruPlanCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'gru-plan',
|
||||||
|
aliases: ['grus-plan', 'gru', 'plan'],
|
||||||
|
group: 'image-edit',
|
||||||
|
memberName: 'gru-plan',
|
||||||
|
description: 'Sends a Gru\'s Plan meme with steps of your choice.',
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 10
|
||||||
|
},
|
||||||
|
clientPermissions: ['ATTACH_FILES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'step1',
|
||||||
|
label: 'step 1',
|
||||||
|
prompt: 'What should the first step of Gru\'s plan be?',
|
||||||
|
type: 'string',
|
||||||
|
max: 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'step2',
|
||||||
|
label: 'step 2',
|
||||||
|
prompt: 'What should the second step of Gru\'s plan be?',
|
||||||
|
type: 'string',
|
||||||
|
max: 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'step3',
|
||||||
|
label: 'step 3',
|
||||||
|
prompt: 'What should the third step of Gru\'s plan be?',
|
||||||
|
type: 'string',
|
||||||
|
max: 500
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { step1, step2, step3 }) {
|
||||||
|
const steps = [step1, step2, step3, step3];
|
||||||
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'gru-plan.png'));
|
||||||
|
const canvas = createCanvas(base.width, base.height);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.drawImage(base, 0, 0);
|
||||||
|
ctx.fillStyle = 'black';
|
||||||
|
ctx.textBaseline = 'top';
|
||||||
|
let i = 0;
|
||||||
|
for (const [x, y] of coord) {
|
||||||
|
const step = steps[i];
|
||||||
|
let fontSize = 50;
|
||||||
|
while (ctx.measureText(step).width > 1500) {
|
||||||
|
fontSize -= 1;
|
||||||
|
ctx.font = `${fontSize}px Noto`;
|
||||||
|
}
|
||||||
|
ctx.fillText(wrapText(ctx, step, 252).join('\n'), x, y);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'gru-plan.png' }] });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -24,10 +24,10 @@ module.exports = class PrimeCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isPrime(number) {
|
isPrime(number) {
|
||||||
if (number < 1) return false;
|
if (number < 2) return false;
|
||||||
for (let i = 2; i < number; i++) {
|
for (let i = 2; i < number; i++) {
|
||||||
if (number % i === 0) return false;
|
if (number % i === 0) return false;
|
||||||
}
|
}
|
||||||
return number !== 1 && number !== 0;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "91.3.1",
|
"version": "91.3.2",
|
||||||
"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