mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Lorem Ipsum Command
This commit is contained in:
@@ -12,5 +12,3 @@ report*.json
|
||||
config.json
|
||||
|
||||
# In-Development Commands
|
||||
assets/json/lorem-ipsum.json
|
||||
commands/random-res/lorem-ipsum.js
|
||||
|
||||
@@ -224,7 +224,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 429
|
||||
Total: 430
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -278,6 +278,7 @@ Total: 429
|
||||
* **joke:** Responds with a random joke.
|
||||
* **kiss-marry-kill:** Determines who to kiss, who to marry, and who to kill.
|
||||
* **light-novel-title:** Responds with a randomly generated Light Novel title.
|
||||
* **lorem-ipsum:** Generates a randomized Lorem Ipsum placeholder text.
|
||||
* **magic-conch:** Asks your question to the Magic Conch.
|
||||
* **name:** Responds with a random name, with the gender of your choice.
|
||||
* **number-fact:** Responds with a random fact about a specific number.
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
[
|
||||
"ad",
|
||||
"adipisicing",
|
||||
"aliqua",
|
||||
"aliquip",
|
||||
"amet",
|
||||
"anim",
|
||||
"aute",
|
||||
"cillum",
|
||||
"commodo",
|
||||
"consectetur",
|
||||
"consequat",
|
||||
"culpa",
|
||||
"cupidatat",
|
||||
"deserunt",
|
||||
"do",
|
||||
"dolor",
|
||||
"dolore",
|
||||
"duis",
|
||||
"ea",
|
||||
"eiusmod",
|
||||
"elit",
|
||||
"enim",
|
||||
"esse",
|
||||
"est",
|
||||
"et",
|
||||
"eu",
|
||||
"ex",
|
||||
"excepteur",
|
||||
"exercitation",
|
||||
"fugiat",
|
||||
"id",
|
||||
"in",
|
||||
"incididunt",
|
||||
"ipsum",
|
||||
"irure",
|
||||
"labore",
|
||||
"laboris",
|
||||
"laborum",
|
||||
"lorem",
|
||||
"magna",
|
||||
"minim",
|
||||
"mollit",
|
||||
"nisi",
|
||||
"non",
|
||||
"nostrud",
|
||||
"nulla",
|
||||
"occaecat",
|
||||
"officia",
|
||||
"pariatur",
|
||||
"proident",
|
||||
"qui",
|
||||
"quis",
|
||||
"reprehenderit",
|
||||
"sint",
|
||||
"sit",
|
||||
"sunt",
|
||||
"tempor",
|
||||
"ullamco",
|
||||
"ut",
|
||||
"velit",
|
||||
"veniam",
|
||||
"voluptate"
|
||||
]
|
||||
@@ -0,0 +1,78 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { firstUpperCase } = require('../../util/Util');
|
||||
const words = require('../../assets/json/lorem-ipsum');
|
||||
const firstSentence = ['Lorem', 'ipsum', 'dolor', 'sit', 'amet,', 'consectetur', 'adipiscing', 'elit'];
|
||||
|
||||
module.exports = class LoremIpsumCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'lorem-ipsum',
|
||||
aliases: ['lorem', 'ipsum'],
|
||||
group: 'random-res',
|
||||
memberName: 'lorem-ipsum',
|
||||
description: 'Generates a randomized Lorem Ipsum placeholder text.',
|
||||
args: [
|
||||
{
|
||||
key: 'characters',
|
||||
prompt: 'How many characters do you want the text to be?',
|
||||
type: 'integer',
|
||||
min: 6,
|
||||
max: 2000
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { characters }) {
|
||||
const result = [];
|
||||
let resultLength = 0;
|
||||
let firstSentenceIndex = 0;
|
||||
let currentSentenceWords = 0;
|
||||
let sentenceStart = true;
|
||||
while (resultLength < characters) {
|
||||
if (firstSentenceIndex === firstSentence.length) {
|
||||
const filterWords = words.filter(word => characters > resultLength + word.length + 1);
|
||||
if (!filterWords.length) {
|
||||
result[result.length - 1] = '.';
|
||||
for (let i = 0; i < characters - resultLength; i++) {
|
||||
const allowedI = [];
|
||||
result.forEach((item, i) => {
|
||||
if (result[i + 1] === '. ') return;
|
||||
if (result[i] === ' ') return;
|
||||
if (result[i] === '. ') return;
|
||||
if (i === result.length - 1) return;
|
||||
if (result[i].endsWith(',')) return;
|
||||
allowedI.push(i);
|
||||
});
|
||||
const chosenI = allowedI[Math.floor(Math.random() * allowedI.length)];
|
||||
const insertPoint = result[chosenI];
|
||||
result[chosenI] = `${insertPoint},`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
const word = filterWords[Math.floor(Math.random() * filterWords.length)];
|
||||
result.push(sentenceStart ? firstUpperCase(word) : word);
|
||||
resultLength += word.length;
|
||||
currentSentenceWords++;
|
||||
if (currentSentenceWords > 0) sentenceStart = false;
|
||||
} else {
|
||||
const word = firstSentence[firstSentenceIndex];
|
||||
result.push(word);
|
||||
firstSentenceIndex++;
|
||||
currentSentenceWords++;
|
||||
resultLength += word.length;
|
||||
if (firstSentenceIndex > 0) sentenceStart = false;
|
||||
}
|
||||
if (currentSentenceWords === 8 || characters - resultLength === 1) {
|
||||
currentSentenceWords = 0;
|
||||
sentenceStart = true;
|
||||
result.push('. ');
|
||||
resultLength += 2;
|
||||
} else {
|
||||
result.push(' ');
|
||||
resultLength += 1;
|
||||
}
|
||||
}
|
||||
return msg.say(result.join(''));
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "114.18.0",
|
||||
"version": "114.19.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user