mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Panik Kalm Panik Command
This commit is contained in:
@@ -243,7 +243,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 528
|
||||
Total: 529
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -706,6 +706,7 @@ Total: 528
|
||||
* **my-collection-grows:** Sends a "My collection grows richer" Nekopara meme with the text of your choice.
|
||||
* **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.
|
||||
* **panik-kalm-panik:** Sends a "Panik, Kalm, Panik" meme with the text of your choice.
|
||||
* **phoebe-teaching-joey:** Sends a "Phoebe Teaching Joey" meme with text of your choice.
|
||||
* **pills:** Sends a "Hard to Swallow Pills" meme with the text of your choice.
|
||||
* **plankton-plan:** Sends a Plankton's Plan meme with steps of your choice.
|
||||
@@ -1099,6 +1100,7 @@ here.
|
||||
* meme-gen-modern ([Noto Font](https://www.google.com/get/noto/))
|
||||
* new-password ([Noto Font](https://www.google.com/get/noto/))
|
||||
* nike-ad ([Noto Font](https://www.google.com/get/noto/))
|
||||
* panik-kalm-panik ([Noto Font](https://www.google.com/get/noto/))
|
||||
* periodic-table ([Noto Font](https://www.google.com/get/noto/))
|
||||
* phoebe-teaching-joey ([Noto Font](https://www.google.com/get/noto/))
|
||||
* pills ([Noto Font](https://www.google.com/get/noto/))
|
||||
@@ -1393,6 +1395,7 @@ here.
|
||||
* if-those-kids-could-read (Concept)
|
||||
* like (Concept)
|
||||
* mario-bros-views (Concept)
|
||||
* panik-kalm-panik (Concept)
|
||||
* pills (Concept)
|
||||
* pogchamp (Concept)
|
||||
* porn (Original Subreddit List)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 177 KiB |
@@ -0,0 +1,108 @@
|
||||
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 PanikKalmPanikCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'panik-kalm-panik',
|
||||
aliases: ['panic-calm-panic'],
|
||||
group: 'edit-meme',
|
||||
memberName: 'panik-kalm-panik',
|
||||
description: 'Sends a "Panik, Kalm, Panik" meme with the text 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: 'Overtime2005',
|
||||
url: 'https://github.com/Overtime2005',
|
||||
reason: 'Concept'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'panik',
|
||||
label: 'first panik',
|
||||
prompt: 'What text should be the first panik?',
|
||||
type: 'string',
|
||||
max: 500
|
||||
},
|
||||
{
|
||||
key: 'kalm',
|
||||
prompt: 'What text should be the kalm?',
|
||||
type: 'string',
|
||||
max: 500
|
||||
},
|
||||
{
|
||||
key: 'panik2',
|
||||
prompt: 'What text should be the second panik?',
|
||||
type: 'string',
|
||||
max: 500
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { panik, kalm, panik2 }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'panik-kalm-panik.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 = '40px Noto';
|
||||
let fontSize = 40;
|
||||
while (ctx.measureText(panik).width > 1136) {
|
||||
fontSize--;
|
||||
ctx.font = `${fontSize}px Noto`;
|
||||
}
|
||||
const panikLines = await wrapText(ctx, panik, 284);
|
||||
const panikTopMost = 130 - (((fontSize * panikLines.length) / 2) + ((10 * (panikLines.length - 1)) / 2));
|
||||
for (let i = 0; i < panikLines.length; i++) {
|
||||
const height = panikTopMost + ((fontSize + 10) * i);
|
||||
ctx.fillText(panikLines[i], 150, height);
|
||||
}
|
||||
ctx.font = '40px Noto';
|
||||
fontSize = 40;
|
||||
while (ctx.measureText(kalm).width > 1136) {
|
||||
fontSize--;
|
||||
ctx.font = `${fontSize}px Noto`;
|
||||
}
|
||||
const kalmLines = await wrapText(ctx, kalm, 284);
|
||||
const kalmTopMost = 430 - (((fontSize * kalmLines.length) / 2) + ((10 * (kalmLines.length - 1)) / 2));
|
||||
for (let i = 0; i < kalmLines.length; i++) {
|
||||
const height = kalmTopMost + ((fontSize + 10) * i);
|
||||
ctx.fillText(kalmLines[i], 150, height);
|
||||
}
|
||||
ctx.font = '40px Noto';
|
||||
fontSize = 40;
|
||||
while (ctx.measureText(panik2).width > 1136) {
|
||||
fontSize--;
|
||||
ctx.font = `${fontSize}px Noto`;
|
||||
}
|
||||
const panik2Lines = await wrapText(ctx, panik2, 284);
|
||||
const panik2TopMost = 730 - (((fontSize * panik2Lines.length) / 2) + ((10 * (panik2Lines.length - 1)) / 2));
|
||||
for (let i = 0; i < panik2Lines.length; i++) {
|
||||
const height = panik2TopMost + ((fontSize + 10) * i);
|
||||
ctx.fillText(panik2Lines[i], 150, height);
|
||||
}
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'panik-kalm-panik.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "119.9.1",
|
||||
"version": "119.10.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user