Edd Facts Book Command

This commit is contained in:
Dragon Fire
2020-06-04 09:48:47 -04:00
parent 06cfa29c38
commit 1f01a643de
4 changed files with 71 additions and 2 deletions
+5 -1
View File
@@ -224,7 +224,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 453
Total: 454
### Utility:
@@ -605,6 +605,7 @@ Total: 453
* **dislike:** Sends an "Everyone Disliked That" meme with the image of your choice.
* **distracted-boyfriend:** Draws three user's avatars over the "Distracted Boyfriend" meme.
* **drakeposting:** Draws two user's avatars over the "Drakeposting" meme.
* **edd-facts-book:** Sends a "Double D's Facts Book" meme with the fact of your choice.
* **food-broke:** Draws a user's avatar over the "Food Broke" meme.
* **genie-rules:** Sends a "There are 4 rules" meme with the text of your choice.
* **girl-worth-fighting-for:** Draws an image or a user's avatar as the object of Ling's affection.
@@ -846,6 +847,8 @@ here.
- [Capcom](http://www.capcom.com/us/)
* ace-attorney ([Images, Original "Ace Attorney" Game](http://www.ace-attorney.com/))
* zero-dialogue ([Image, Original "Megaman Zero" Game](http://megaman.capcom.com/))
- [Cartoon Network](https://www.cartoonnetworkme.com/)
* edd-facts-book ([Image, Original "Ed, Edd n Eddy" TV Series](https://www.cartoonnetworkme.com/show/ed-edd-n-eddy))
- [cheesecakejedi](https://imgur.com/user/cheesecakejedi)
* axis-cult-sign-up ([Image](https://imgur.com/gallery/quQTD))
- [Cheng Xiao](https://www.instagram.com/chengxiao_0715/)
@@ -956,6 +959,7 @@ here.
* catch ([Noto Font](https://www.google.com/get/noto/))
* dear-liberals ([Oswald Font](https://fonts.google.com/specimen/Oswald))
* demotivational ([Noto Font](https://www.google.com/get/noto/))
* edd-facts-book ([Noto Font](https://www.google.com/get/noto/))
* genie-rules ([Noto Font](https://www.google.com/get/noto/))
* google ([Custom Search API](https://cse.google.com/cse/all))
* google-autofill (Autofill API)
Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

+65
View File
@@ -0,0 +1,65 @@
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' });
module.exports = class EddFactsBookCommand extends Command {
constructor(client) {
super(client, {
name: 'edd-facts-book',
aliases: ['edd-fact-book', 'double-d-facts-book', 'double-d-fact-book', 'edd-facts', 'edd-fact'],
group: 'edit-meme',
memberName: 'edd-facts-book',
description: 'Sends a "Double D\'s Facts Book" meme with the fact of your choice.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Google',
url: 'https://www.google.com/',
reason: 'Noto Font',
reasonURL: 'https://www.google.com/get/noto/'
},
{
name: 'Cartoon Network',
url: 'https://www.cartoonnetworkme.com/',
reason: 'Image, Original "Ed, Edd n Eddy" TV Series',
reasonURL: 'https://www.cartoonnetworkme.com/show/ed-edd-n-eddy'
}
],
args: [
{
key: 'fact',
prompt: 'What should the fact on Edd\'s book be?',
type: 'string',
max: 500
}
]
});
}
async run(msg, { fact }) {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'edd-facts-book.png'));
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.textBaseline = 'top';
ctx.drawImage(base, 0, 0);
ctx.rotate(-15 * (Math.PI / 180));
ctx.font = '30px Noto';
let fontSize = 30;
while (ctx.measureText(first).width > 549) {
fontSize -= 1;
ctx.font = `${fontSize}px Noto`;
}
const lines = await wrapText(ctx, fact, 183);
ctx.fillText(lines.join('\n'), 119, 306, 183);
ctx.rotate(15 * (Math.PI / 180));
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'edd-facts-book.png' }] });
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "115.3.0",
"version": "115.4.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {