mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 06:45:31 +02:00
Illegal, Karen, better ping
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const path = require('path');
|
||||
const { shortenText } = 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' });
|
||||
|
||||
module.exports = class IllegalCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'illegal',
|
||||
aliases: ['is-now-illegal', 'trump', 'first-order-of-business'],
|
||||
group: 'image-edit',
|
||||
memberName: 'illegal',
|
||||
description: 'Makes President Trump make your text illegal.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What should the text of the bill be?',
|
||||
type: 'string',
|
||||
parse: text => text.toUpperCase()
|
||||
},
|
||||
{
|
||||
key: 'isOrAre',
|
||||
label: 'is or are',
|
||||
prompt: 'Should the text use is or are?',
|
||||
type: 'string',
|
||||
default: 'is',
|
||||
validate: isOrAre => {
|
||||
if (['is', 'are'].includes(isOrAre.toLowerCase())) return true;
|
||||
return 'Invalid is or are, please enter either is or are.';
|
||||
},
|
||||
parse: isOrAre => isOrAre.toUpperCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { text, isOrAre }) {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'illegal.png'));
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.rotate(7 * (Math.PI / 180));
|
||||
ctx.font = '37px Noto';
|
||||
ctx.fillText(stripIndents`
|
||||
${shortenText(ctx, text, 215)}
|
||||
${isOrAre} NOW
|
||||
ILLEGAL.
|
||||
`, 690, 350);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'illegal.png' }] });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user