mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-15 00:12:38 +02:00
Better Error Handling
This commit is contained in:
@@ -20,9 +20,8 @@ module.exports = class BinaryCommand extends Command {
|
||||
prompt: 'What text would you like to convert to binary?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if(binary(text).length < 2000)
|
||||
return true;
|
||||
return 'Your message content is too long.';
|
||||
if(binary(text).length < 2000) return true;
|
||||
return 'Your text is too long.';
|
||||
},
|
||||
parse: text => binary(text)
|
||||
}
|
||||
|
||||
@@ -14,9 +14,8 @@ module.exports = class CowsayCommand extends Command {
|
||||
prompt: 'What text would you like the cow to say?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if(text.length < 1500)
|
||||
return true;
|
||||
return `Please keep your content under 1500 characters, you have ${text.length}.`;
|
||||
if(text.length < 1500) return true;
|
||||
return 'Invalid Text. Text must be under 1500 characters.';
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -15,9 +15,8 @@ module.exports = class MorseCommand extends Command {
|
||||
prompt: 'What text would you like to convert to morse?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if(letterTrans(text, dictionary, ' ').length < 1999)
|
||||
return true;
|
||||
return 'Your message content is too long.';
|
||||
if(letterTrans(text, dictionary, ' ').length < 1999) return true;
|
||||
return 'Your text is too long.';
|
||||
},
|
||||
parse: text => letterTrans(text.toLowerCase(), dictionary, ' ')
|
||||
}
|
||||
|
||||
@@ -15,9 +15,8 @@ module.exports = class PirateCommand extends Command {
|
||||
prompt: 'What text would you like to convert to pirate?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if(wordTrans(text, dictionary).length < 1999)
|
||||
return true;
|
||||
return 'Your message content is too long.';
|
||||
if(wordTrans(text, dictionary).length < 1999) return true;
|
||||
return 'Your text is too long.';
|
||||
},
|
||||
parse: text => wordTrans(text, dictionary)
|
||||
}
|
||||
|
||||
@@ -15,9 +15,8 @@ module.exports = class TemmieCommand extends Command {
|
||||
prompt: 'What text would you like to convert to Temmie speak?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if(wordTrans(text, dictionary).length < 1999)
|
||||
return true;
|
||||
return 'Your message content is too long.';
|
||||
if(wordTrans(text, dictionary).length < 1999) return true;
|
||||
return 'Your text is too long.';
|
||||
},
|
||||
parse: text => wordTrans(text, dictionary)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = class WebhookCommand extends Command {
|
||||
.send({ content });
|
||||
return null;
|
||||
} catch(err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
return msg.say(`An Error Occurred: ${err}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,9 +14,8 @@ module.exports = class ZalgoCommand extends Command {
|
||||
prompt: 'What text would you like to convert to zalgo?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if(text.length < 500)
|
||||
return true;
|
||||
return `Please keep your text under 500 characters, you have ${text.length}.`;
|
||||
if(text.length < 500) return true;
|
||||
return 'Invalid Text. Text must be under 500 characters.';
|
||||
},
|
||||
parse: text => zalgo(text)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user