Gandhi Quote Command

This commit is contained in:
Dragon Fire
2020-07-04 23:07:40 -04:00
parent 58307be5a8
commit 7bec6d1639
6 changed files with 76 additions and 4 deletions
+5 -1
View File
@@ -243,7 +243,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 525
Total: 526
### Utility:
@@ -597,6 +597,7 @@ Total: 525
* **fire-frame:** Draws a fiery border over an image or a user's avatar.
* **fish-eye:** Draws an image or a user's avatar but with a fish-eye lens.
* **frame:** Draws a frame around an image or a user's avatar.
* **gandhi-quote:** Makes Mahatma Gandhi say the quote you want.
* **ghost:** Draws an image or a user's avatar but with a ghost-like transparency.
* **glass-shatter:** Draws an image or a user's avatar with a glass shatter in front of it.
* **glitch:** Draws an image or a user's avatar but glitched.
@@ -1122,6 +1123,8 @@ here.
* word-chain ([Moby Word Lists](http://www.gutenberg.org/ebooks/3201))
- [Gravatar](https://en.gravatar.com/)
* gravatar ([API](https://en.gravatar.com/site/implement/))
- [GUST e-foundry](https://www.fontsquirrel.com/fonts/list/foundry/gust-e-foundry)
* gandhi-quote ([Latin Modern Roman Font](https://www.fontsquirrel.com/fonts/Latin-Modern-Roman))
- [Hackyon](http://www.hackyon.com/playground/fisheye/)
* fish-eye (Fish-Eye Code)
- [Hasbro](https://shop.hasbro.com/en-us)
@@ -1378,6 +1381,7 @@ here.
* dislike (Concept)
* enslaved (Concept)
* for-five-hours (Concept)
* gandhi-quote (Concept)
* gun (Concept)
* hands (Concept)
* hentai (Original Subreddit List)
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

+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', 'lmroman10-italic.otf'), {
family: 'Latin Modern Roman',
weight: 'italic'
});
module.exports = class GandhiQuoteCommand extends Command {
constructor(client) {
super(client, {
name: 'gandhi-quote',
aliases: ['gandhi', 'mahatma-gandhi', 'mahatma-gandhi-quote'],
group: 'edit-meme',
memberName: 'gandhi-quote',
description: 'Makes Mahatma Gandhi say the quote you want.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'GUST e-foundry',
url: 'https://www.fontsquirrel.com/fonts/list/foundry/gust-e-foundry',
reason: 'Latin Modern Roman Font',
reasonURL: 'https://www.fontsquirrel.com/fonts/Latin-Modern-Roman'
},
{
name: 'Overtime2005',
url: 'https://github.com/Overtime2005',
reason: 'Concept'
}
],
args: [
{
key: 'quote',
prompt: 'What quote should Gandhi say?',
type: 'string',
max: 500
}
]
});
}
async run(msg, { text }) {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'gandhi-quote.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 = 'normal italic 50px Latin Modern Roman';
let fontSize = 50;
while (ctx.measureText(text).width > 1485) {
fontSize--;
ctx.font = `${fontSize}px Noto`;
}
const lines = await wrapText(ctx, text, 270);
const topMost = 180 - (((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], 395, height);
}
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'gandhi-quote.png' }] });
}
};
+2 -2
View File
@@ -73,7 +73,7 @@ module.exports = class MarioBrosViewsCommand extends Command {
ctx.fillStyle = 'white';
ctx.font = '36px Noto';
let fontSize = 36;
while (ctx.measureText(mario).width > 900) {
while (ctx.measureText(mario).width > 800) {
fontSize--;
ctx.font = `${fontSize}px Noto`;
}
@@ -88,7 +88,7 @@ module.exports = class MarioBrosViewsCommand extends Command {
}
ctx.font = '36px Noto';
fontSize = 36;
while (ctx.measureText(luigi).width > 900) {
while (ctx.measureText(luigi).width > 800) {
fontSize--;
ctx.font = `${fontSize}px Noto`;
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "119.7.4",
"version": "119.8.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {