Change My Mind Command

This commit is contained in:
Dragon Fire
2020-06-10 10:40:41 -04:00
parent 5b2fbe537d
commit 0d783b76ad
4 changed files with 71 additions and 2 deletions
+5 -1
View File
@@ -226,7 +226,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 470
Total: 471
### Utility:
@@ -622,6 +622,7 @@ Total: 470
* **beautiful:** Draws a user's avatar over Gravity Falls' "Oh, this? This is beautiful." meme.
* **catch:** Catch users, revealing who is something.
* **challenger:** Draws an image or a user's avatar over Smash Bros.'s "Challenger Approaching" screen.
* **change-my-mind:** Sends a "Change My Mind" meme with the text of your choice.
* **chi-idea:** Sends a "Daddy, I've got an idea!" Takagi-san meme with the text of your choice.
* **cursed-sponge:** Sends a cursed sponge duplicated however many times you want.
* **dear-liberals:** Sends a "Dear Liberals" meme with words of your choice.
@@ -985,6 +986,7 @@ here.
* book ([Books API](https://developers.google.com/books/))
* calendar ([Calendar API](https://developers.google.com/calendar/))
* catch ([Noto Font](https://www.google.com/get/noto/))
* change-my-mind ([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/))
@@ -1376,6 +1378,8 @@ here.
* steam-card ([Original Design](https://steamcommunity.com/tradingcards/))
* steam-now-playing (Original Design)
* steam-now-playing-classic (Original Design)
- [Steven Crowder](https://www.youtube.com/StevenCrowder)
* change-my-mind (Image)
- [Straw Poll](https://www.strawpoll.me/)
* strawpoll ([API](https://github.com/strawpoll/strawpoll/wiki/API))
- [Superpower Wiki](https://powerlisting.fandom.com/wiki/Superpower_Wiki)
Binary file not shown.

After

Width:  |  Height:  |  Size: 303 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 ChangeMyMindCommand extends Command {
constructor(client) {
super(client, {
name: 'change-my-mind',
aliases: ['change-mind', 'mind-change'],
group: 'edit-meme',
memberName: 'change-my-mind',
description: 'Sends a "Change My Mind" meme with the text of your choice.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Steven Crowder',
url: 'https://www.youtube.com/StevenCrowder',
reason: 'Image',
reasonURL: 'https://twitter.com/scrowder/status/964577508447449088'
},
{
name: 'Google',
url: 'https://www.google.com/',
reason: 'Noto Font',
reasonURL: 'https://www.google.com/get/noto/'
}
],
args: [
{
key: 'text',
prompt: 'What should be on the poster?',
type: 'string',
max: 500
}
]
});
}
async run(msg, { text }) {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'change-my-mind.png'));
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.textBaseline = 'top';
ctx.drawImage(base, 0, 0);
ctx.rotate(6 * (Math.PI / 180));
ctx.font = '28px Noto';
let fontSize = 28;
while (ctx.measureText(text).width > 309) {
fontSize--;
ctx.font = `${fontSize}px Noto`;
}
const lines = await wrapText(ctx, text, 206);
ctx.fillText(lines.join('\n'), 184, 253, 206);
ctx.rotate(-6 * (Math.PI / 180));
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'change-my-mind.png' }] });
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "116.13.4",
"version": "116.14.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {