Scroll of Truth Command

This commit is contained in:
Dragon Fire
2020-05-31 10:22:00 -04:00
parent bb537cc455
commit 19f7660fdf
4 changed files with 74 additions and 2 deletions
+5 -1
View File
@@ -224,7 +224,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 447
Total: 448
### Utility:
@@ -615,6 +615,7 @@ Total: 447
* **new-password:** Sends a "Weak Password/Strong Password" meme with the passwords of your choice.
* **nike-ad:** Sends a "Believe in Something" Nike Ad meme with the text of your choice.
* **plankton-plan:** Sends a Plankton's Plan meme with steps of your choice.
* **scroll-of-truth:** Sends a "Scroll of Truth" meme with the text of your choice.
* **skyrim-skill:** Sends a "Skyrim Skill" meme with the skill and image of your choice.
* **sora-selfie:** Draws an image or a user's avatar behind Sora taking a selfie.
* **sos:** Sends a "Esther Verkest's Help Sign" comic with the text of your choice.
@@ -963,6 +964,7 @@ here.
* nike-ad ([Noto Font](https://www.google.com/get/noto/))
* periodic-table ([Noto Font](https://www.google.com/get/noto/))
* plankton-plan ([Noto Font](https://www.google.com/get/noto/))
* scroll-of-truth ([Noto Font](https://www.google.com/get/noto/))
* sos ([Noto Font](https://www.google.com/get/noto/))
* spongebob-burn ([Noto Font](https://www.google.com/get/noto/))
* steam-card ([Noto Font](https://www.google.com/get/noto/))
@@ -1283,6 +1285,8 @@ here.
* league-of-legends ([API](https://developer.riotgames.com/))
- [RoboHash](https://robohash.org/)
* robohash (API)
- [Robotatertot](https://robotatertot.tumblr.com/)
* scroll-of-truth ([Image](https://robotatertot.tumblr.com/post/156736308530/truth))
- [RogerHub Final Grade Calculator](https://rogerhub.com/final-grade-calculator/)
* final-grade (Concept, Code)
- [Rotten Tomatoes](https://www.rottentomatoes.com/)
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

+68
View File
@@ -0,0 +1,68 @@
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 ScrollOfTruthCommand extends Command {
constructor(client) {
super(client, {
name: 'scroll-of-truth',
aliases: ['truth', 'scroll', 'truth-scroll', 'scroll-truth'],
group: 'edit-meme',
memberName: 'scroll-of-truth',
description: 'Sends a "Scroll of Truth" meme with the text of your choice.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Robotatertot',
url: 'https://robotatertot.tumblr.com/',
reason: 'Image',
reasonURL: 'https://robotatertot.tumblr.com/post/156736308530/truth'
},
{
name: 'Google',
url: 'https://www.google.com/',
reason: 'Noto Font',
reasonURL: 'https://www.google.com/get/noto/'
}
],
args: [
{
key: 'text',
prompt: 'What do you want the scroll of truth to say?',
type: 'string',
max: 500
}
]
});
}
async run(msg, { text }) {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'scroll-of-truth.png'));
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
ctx.font = '60px Noto';
let fontSize = 60;
while (ctx.measureText(text).width > 678) {
fontSize -= 1;
ctx.font = `${fontSize}px Noto`;
}
const lines = await wrapText(ctx, text, 226);
const topMost = 724 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
for (let i = 0; i < lines.length; i++) {
const height = topMost + ((fontSize + 20) * i);
ctx.fillText(lines[i], 240, height);
}
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'scroll-of-truth.png' }] });
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "114.32.0",
"version": "114.33.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {