mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-14 15:57:42 +02:00
Better Validators and More Destucturing
This commit is contained in:
@@ -21,10 +21,10 @@ module.exports = class BinaryCommand extends Command {
|
||||
prompt: 'What text would you like to convert to binary?',
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (stringToBinary(content).length > 1950) {
|
||||
return 'Your message content is too long.';
|
||||
if (stringToBinary(content).length < 2000) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return 'Your message content is too long.';
|
||||
},
|
||||
parse: text => {
|
||||
return stringToBinary(text);
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = class CowsayCommand extends Command {
|
||||
if (text.length < 1500) {
|
||||
return true;
|
||||
}
|
||||
return 'Your message content is too long.';
|
||||
return `Please keep your content under 1500 characters, you have ${text.length}.`;
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -18,10 +18,10 @@ module.exports = class MorseCommand extends Command {
|
||||
prompt: 'What text would you like to convert to morse?',
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (translator.letterTrans(content, dictionary, ' ').length < 1900) {
|
||||
if (translator.letterTrans(content, dictionary, ' ').length < 1999) {
|
||||
return true;
|
||||
}
|
||||
return 'Your text to encode is too long.';
|
||||
return 'Your message content is too long.';
|
||||
},
|
||||
parse: text => {
|
||||
return translator.letterTrans(text.toLowerCase(), dictionary, ' ');
|
||||
|
||||
@@ -19,10 +19,10 @@ module.exports = class PirateCommand extends Command {
|
||||
prompt: 'What text would you like to convert to pirate?',
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (translator.wordTrans(content, dictionary).length > 1950) {
|
||||
return 'Your message content is too long.';
|
||||
if (translator.wordTrans(content, dictionary).length < 1999) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return 'Your message content is too long.';
|
||||
},
|
||||
parse: text => {
|
||||
return translator.wordTrans(text, dictionary);
|
||||
|
||||
@@ -15,10 +15,10 @@ module.exports = class TemmieCommand extends Command {
|
||||
prompt: 'What text would you like to convert to Temmie speak?',
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (translator.wordTrans(content, dictionary).length > 1950) {
|
||||
return 'Your message content is too long.';
|
||||
if (translator.wordTrans(content, dictionary).length < 1999) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return 'Your message content is too long.';
|
||||
},
|
||||
parse: text => {
|
||||
return translator.wordTrans(text, dictionary);
|
||||
|
||||
@@ -14,10 +14,10 @@ module.exports = class ZalgoCommand extends Command {
|
||||
prompt: 'What text would you like to convert to zalgo?',
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (zalgo(content).length > 1950) {
|
||||
return 'Your message content is too long.';
|
||||
if (content.length > 500) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return `Please keep your text under 500 characters, you have ${content.length}.`;
|
||||
},
|
||||
parse: text => {
|
||||
return zalgo(text);
|
||||
|
||||
Reference in New Issue
Block a user