mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-09 01:04:16 +02:00
Validators Added for all Commands
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"banned": {
|
||||
"155112606661607425": "155112606661607425",
|
||||
"242699360352206850": "242699360352206850"
|
||||
"155112606661607425": "155112606661607425"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,13 @@ module.exports = class TypingGameCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'difficulty',
|
||||
prompt: 'What difficulty should the typing game be? Easy, Medium, Hard, or Extreme?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: difficulty => {
|
||||
if (difficulty.toLowerCase() === 'easy' || difficulty.toLowerCase() === 'medium' || difficulty.toLowerCase() === 'hard' || difficulty.toLowerCase() === 'extreme') {
|
||||
return true;
|
||||
}
|
||||
return 'Please set the difficulty to either `easy`, `medium`, `hard`, or `extreme`.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -112,11 +112,23 @@ module.exports = class MemeCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'type',
|
||||
prompt: 'What meme type do you want to use?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: type => {
|
||||
if (memecodes[type.toLowerCase()] || type.toLowerCase() === 'list') {
|
||||
return true;
|
||||
}
|
||||
return 'Please enter a valid meme type. Enter `list` to view a list of types.';
|
||||
}
|
||||
}, {
|
||||
key: 'content',
|
||||
prompt: 'What should the meme content be?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (content.includes(' | ') && content.match(/^[a-zA-Z0-9|.,!?'-\s]+$/)) {
|
||||
return true;
|
||||
}
|
||||
return 'Please split your choices with ` | ` and do not use special characters.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -127,9 +139,7 @@ module.exports = class MemeCommand extends commando.Command {
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let type = args.type.toLowerCase();
|
||||
if (!memecodes[type] || type !== 'list') return message.channel.send(':x: Error! Meme type not found! Use `;meme list` to view a list of meme types.');
|
||||
let content = args.content;
|
||||
if (!content.includes(' | ') || !content.match(/^[a-zA-Z0-9|.,!?'-\s]+$/)) return message.channel.send(':x: Error! Invalid content! Split your choices with a " | " or do not use special characters!');
|
||||
if (type === "list") return message.channel.send("**Type Codes:** tenguy, afraid, older, aag, tried, biw, blb, kermit, bd, ch, cbg, wonka, cb, keanu, dsm, live, ants, doge, alwaysonbeat, ermg, facepalm, fwp, fa, fbf, fry, hipster, icanhas, crazypills, mw, noidea, regret, boat, hagrid, sohappy, captain, inigo, iw, ackbar, happening, joker, ive, ll, morpheus, mb, badchoice, mmm, jetpack, red, mordor, oprah, oag, remembers, philosoraptor, jw, patrick, rollsafe, sad-obama, sad-clinton, sadfrog, sad-bush, sad-biden, sad-boehner, saltbae, sarcasticbear, dwight, sb, ss, sf, dodgson, money, sohot, nice, awesome-awkward, awesome, awkward-awesome, awkward, fetch, success, scc, ski, officespace, interesting, toohigh, bs, center, both, winter, xy, buzz, yodawg, uno, yallgot, bad, elf, chosen");
|
||||
let memeQuery = content.split(" ").join("-").split("-|-");
|
||||
let toprow = memeQuery[0].split("?").join("~q");
|
||||
|
||||
@@ -12,7 +12,13 @@ module.exports = class RomanCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'number',
|
||||
prompt: 'What do you want to convert to Roman?',
|
||||
type: 'integer'
|
||||
type: 'integer',
|
||||
validate: number => {
|
||||
if (number > 1000000) {
|
||||
return 'Please enter a number below one million.';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -24,7 +30,6 @@ module.exports = class RomanCommand extends commando.Command {
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let numberToRoman = args.number;
|
||||
let romanInterger = numberToRoman;
|
||||
if (romanInterger > 1000000) return message.channel.send(':x: Error! Number is too high!');
|
||||
return message.channel.send(romanNumeralConverter.getRomanFromInteger(romanInterger));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,7 +17,13 @@ module.exports = class SoundBoardCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'sound',
|
||||
prompt: 'What sound do you want me to play?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: sound => {
|
||||
if (sound.avaliable[sound.toLowerCase()] || sound.toLowerCase() === 'list') {
|
||||
return true;
|
||||
}
|
||||
return 'Sound not found. Enter `list` to view a list of sounds.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -29,9 +35,8 @@ module.exports = class SoundBoardCommand extends commando.Command {
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let voiceChannel = message.member.voiceChannel;
|
||||
if (!voiceChannel) return message.channel.send(`:x: Error! Please be in a voice channel first!`);
|
||||
let soundToPlay = args.sound;
|
||||
let soundToPlay = args.sound.toLowerCase();
|
||||
if (soundToPlay === 'list') return message.channel.send("**Available Sounds:** Cat, Pikachu, Vader, Doh, It's a Trap, Mario Death, Pokemon Center, Dun Dun Dun, Spongebob, Ugly Barnacle, Woo Hoo, Space, GLaDOS Bird, Airhorn, Zelda Chest, Eat my Shorts, No This is Patrick, Wumbo");
|
||||
if (soundToPlay !== sounds.avaliable[soundToPlay]) return message.channel.send(':x: Error! Sound not found! Use `;soundboard list` to see a list of sounds you can play.');
|
||||
let alreadyConnected = await this.client.voiceConnections.get(voiceChannel.guild.id);
|
||||
if (alreadyConnected) {
|
||||
if (alreadyConnected.channel.id === voiceChannel.id) return message.channel.send(':x: Error! I am already playing a sound!');
|
||||
|
||||
@@ -14,7 +14,13 @@ module.exports = class ChooseCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'choices',
|
||||
prompt: 'What choices do you want me pick from? Split them with " | "!',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (content.includes(' | ')) {
|
||||
return true;
|
||||
}
|
||||
return 'Please split your choices with ` | `.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,7 +15,13 @@ module.exports = class RandomNameGen extends commando.Command {
|
||||
args: [{
|
||||
key: 'gender',
|
||||
prompt: 'Which gender do you want to generate a name for?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: gender => {
|
||||
if (gender.toLowerCase() === 'male' || gender.toLowerCase() === 'female') {
|
||||
return true;
|
||||
}
|
||||
return 'Please enter either `male` or `female`.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -38,8 +44,5 @@ module.exports = class RandomNameGen extends commando.Command {
|
||||
else if (gender === "female") {
|
||||
return message.channel.send(`${randomFirstFemale} ${randomLast}`);
|
||||
}
|
||||
else {
|
||||
return message.channel.send(':x: Error! Please set either male or female!');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,7 +18,13 @@ module.exports = class BotSearchCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'bot',
|
||||
prompt: 'Which bot do you want to get information for?',
|
||||
type: 'user'
|
||||
type: 'user',
|
||||
validate: user => {
|
||||
if (user.bot) {
|
||||
return true;
|
||||
}
|
||||
return 'Please mention a bot account, not a user account.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,7 +16,13 @@ module.exports = class DiscrimCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'discrim',
|
||||
prompt: 'Which discriminator would you like to search for?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: discrim => {
|
||||
if (discrim.match(/^[0-9]+$/) || discrim.length === 4) {
|
||||
return true;
|
||||
}
|
||||
return 'Invalid discriminator.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -27,7 +33,6 @@ module.exports = class DiscrimCommand extends commando.Command {
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let userToSearch = args.discrim;
|
||||
if (!userToSearch.match(/^[0-9]+$/) || userToSearch.length !== 4) return message.channel.send(':x: Error! Invalid Discriminator!');
|
||||
let users = await this.client.users.filter(u => u.discriminator === userToSearch).map(u => u.username).sort();
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle(`${users.length} Users with the discriminator: ${userToSearch}`)
|
||||
|
||||
@@ -16,7 +16,13 @@ module.exports = class PokedexCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'pokemon',
|
||||
prompt: 'What Pokémon would you like to get info on?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: pokemon => {
|
||||
if (pokedex.name[pokemon.toLowerCase()]) {
|
||||
return true;
|
||||
}
|
||||
return 'Please enter a valid Pokémon from either Kanto or Johto.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -26,8 +32,7 @@ module.exports = class PokedexCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let pokemon = args.pokemon;
|
||||
if (!pokedex.name[pokemon.toLowerCase()]) return message.channel.send(':x: Error! This Pokémon is either not valid, or is not yet implemented!');
|
||||
let pokemon = args.pokemon.toLowerCase();
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle('Information')
|
||||
.setAuthor(`#${pokedex.index[pokemon]} ${pokedex.name[pokemon]}`, `http://www.serebii.net/pokedex-sm/icon/${pokedex.index[pokemon]}.png`)
|
||||
|
||||
@@ -15,7 +15,13 @@ module.exports = class MorseCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'method',
|
||||
prompt: 'Would you like to encode or decode the text?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: method => {
|
||||
if (method.toLowerCase() === 'encode' || method.toLowerCase() === 'decode') {
|
||||
return true;
|
||||
}
|
||||
return 'Please enter either `encode` or `decode`.'
|
||||
}
|
||||
}, {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to convert to morse?',
|
||||
@@ -29,10 +35,13 @@ module.exports = class MorseCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let methodToUse = args.method;
|
||||
if (methodToUse.toLowerCase() !== 'encode' || methodToUse.toLowerCase() !== 'decode') return message.channel.send(':x: Error! Please set either encode or decode!');
|
||||
let methodToUse = args.method.toLowerCase();
|
||||
let toMorse = args.text;
|
||||
if (methodToUse === 'encode') return message.channel.send(morse.encode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
|
||||
if (methodToUse === 'decode') return message.channel.send(morse.decode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
|
||||
if (methodToUse === 'encode') {
|
||||
return message.channel.send(morse.encode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
|
||||
}
|
||||
else if (methodToUse === 'decode') {
|
||||
return message.channel.send(morse.decode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,7 +15,13 @@ module.exports = class RomajiCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'kana',
|
||||
prompt: 'What kana would you like to convert to romaji?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: kana => {
|
||||
if (hepburn.containsKana(kana)) {
|
||||
return true;
|
||||
}
|
||||
return 'Please enter text in either Hiragana or Katakana.';
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -26,7 +32,6 @@ module.exports = class RomajiCommand extends commando.Command {
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let romajify = args.kana;
|
||||
if (!hepburn.containsKana(romajify)) return message.channel.send(':x: Error! Message contains no Katakana or Hiragana!');
|
||||
let romajified = hepburn.fromKana(romajify);
|
||||
if (romajified.length > 1950) return message.channel.send(":x: Error! Your message is too long!");
|
||||
return message.channel.send(romajified);
|
||||
|
||||
@@ -120,11 +120,23 @@ module.exports = class TranslateCommand extends commando.Command {
|
||||
args: [{
|
||||
key: 'to',
|
||||
prompt: 'What language would you like to translate to?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: to => {
|
||||
if (languages[to.toLowerCase()] || to.toLowerCase() === 'list') {
|
||||
return true;
|
||||
}
|
||||
return 'Please enter a valid language code. Enter `list` for a list of codes.';
|
||||
}
|
||||
}, {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to translate?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
validate: content => {
|
||||
if (content.length > 200) {
|
||||
return 'Please keep translation queries under 200 characters.';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -134,11 +146,9 @@ module.exports = class TranslateCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let languageto = args.to;
|
||||
if (!languages[languageto] || languageto.toLowerCase() !== 'list') return message.channel.send(':x: Error! Translation type is not valid!');
|
||||
let languageto = args.to.toLowerCase();
|
||||
let thingToTranslate = args.text;
|
||||
if (languageto === "list") return message.channel.send("‘af': 'Afrikaans’\n’sq': 'Albanian'\n'ar': 'Arabic’\n’hy': 'Armenian’\n’az': 'Azerbaijani’\n’eu': 'Basque’\n’be': 'Belarusian’\n’bn': 'Bengali’\n’bs': 'Bosnian’\n’bg': 'Bulgarian’\n’ca': 'Catalan’\n’ceb': 'Cebuano’\n’ny': 'Chichewa’\n’zh-cn': 'Chinese Simplified’\n’zh-tw': 'Chinese Traditional’\n’co': 'Corsican’\n’hr': 'Croatian’\n’cs': 'Czech’\n’da': 'Danish’\n’nl': 'Dutch’\n’en': 'English’\n’eo': 'Esperanto’\n’et': 'Estonian’\n’tl': 'Filipino’\n’fi': 'Finnish’\n’fr': 'French’\n’fy': 'Frisian’\n’gl': 'Galician’\n’ka': 'Georgian’\n’de': 'German’\n’el': 'Greek’\n’gu': 'Gujarati’\n’ht': 'Haitian Creole’\n’ha': 'Hausa’\n’haw': 'Hawaiian’\n’iw': 'Hebrew’\n’hi': 'Hindi’\n’hmn': 'Hmong’\n’hu': 'Hungarian’\n’is': 'Icelandic’\n’ig': 'Igbo’\n’id': 'Indonesian’\n’ga': 'Irish’\n’it': 'Italian’\n’ja': 'Japanese’\n’jw': 'Javanese’\n’kn': 'Kannada’\n’kk': 'Kazakh’\n’km': 'Khmer’\n’ko': 'Korean’\n’ku': 'Kurdish (Kurmanji)’\n’ky': 'Kyrgyz’\n’lo': 'Lao’\n’la': 'Latin’\n’lv': 'Latvian’\n’lt': 'Lithuanian’\n’lb': 'Luxembourgish’\n’mk': 'Macedonian’\n’mg': 'Malagasy’\n’ms': 'Malay’\n’ml': 'Malayalam’\n’mt': 'Maltese’\n’mi': 'Maori’\n’mr': 'Marathi’\n’mn': 'Mongolian’\n’my': 'Myanmar (Burmese)’\n’ne': 'Nepali’\n’no': 'Norwegian’\n’ps': 'Pashto’\n’fa': 'Persian’\n’pl': 'Polish’\n’pt': 'Portuguese’\n’ma': 'Punjabi’\n’ro': 'Romanian’\n’ru': 'Russian’\nsm': 'Samoan’\n’gd': 'Scots Gaelic’\n’sr': 'Serbian’\n’st': 'Sesotho’\n’sn': 'Shona’\n’sd': 'Sindhi’\n’si': 'Sinhala’\n’sk': 'Slovak’\n’sl': 'Slovenian’\n’so': 'Somali’\n’es': 'Spanish’\n’su': 'Sudanese’\n’sw': 'Swahili’\n’sv': 'Swedish’\n’tg': 'Tajik’\n’ta': 'Tamil’\n’te': 'Telugu’\n’th': 'Thai’\n’tr': 'Turkish’\n’uk': 'Ukrainian’\n’ur': 'Urdu’\n’uz': 'Uzbek’\n’vi': 'Vietnamese’\n’cy': 'Welsh’\n’xh': 'Xhosa’\n’yi': 'Yiddish’\n’yo': 'Yoruba’\n’zu': 'Zulu'");
|
||||
if (thingToTranslate.length > 200) return message.channel.send(":x: Error! Please keep translations below 200 characters!");
|
||||
try {
|
||||
let res = await translate(thingToTranslate, {
|
||||
to: languageto
|
||||
|
||||
Reference in New Issue
Block a user