diff --git a/commands/games/hunger-games.js b/commands/games/hunger-games.js index 2c445a07..ed854d3f 100644 --- a/commands/games/hunger-games.js +++ b/commands/games/hunger-games.js @@ -17,10 +17,7 @@ module.exports = class HungerGamesCommand extends Command { prompt: 'Who should compete in the games? Up to 24 tributes can participate.', type: 'string', infinite: true, - validate: tribute => { - if (tribute.length < 25) return true; - return 'Invalid tribute, please keep each tribute under 25 characters.'; - } + max: 25 } ] }); diff --git a/commands/image-edit/meme.js b/commands/image-edit/meme.js index d30f8101..175bc9f0 100644 --- a/commands/image-edit/meme.js +++ b/commands/image-edit/meme.js @@ -20,20 +20,14 @@ module.exports = class MemeCommand extends Command { key: 'top', prompt: 'What should the top row of the meme to be?', type: 'string', - validate: top => { - if (top.length < 200) return true; - return 'Invalid top text, please keep the top text under 200 characters.'; - }, + max: 200, parse: top => encodeURIComponent(top) }, { key: 'bottom', prompt: 'What should the bottom row of the meme to be?', type: 'string', - validate: bottom => { - if (bottom.length < 200) return true; - return 'Invalid bottom text, please keep the bottom text under 200 characters.'; - }, + max: 200, parse: bottom => encodeURIComponent(bottom) } ] diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 3278c7df..f07d0220 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -23,10 +23,7 @@ module.exports = class BanCommand extends Command { key: 'reason', prompt: 'What do you want to set the reason as?', type: 'string', - validate: reason => { - if (reason.length < 140) return true; - return 'Invalid reason, please keep the reason under 140 characters.'; - } + max: 140 } ] }); diff --git a/commands/moderation/hackban.js b/commands/moderation/hackban.js index a4b3c4fa..87c6f3c9 100644 --- a/commands/moderation/hackban.js +++ b/commands/moderation/hackban.js @@ -16,16 +16,17 @@ module.exports = class HackbanCommand extends Command { { key: 'id', prompt: 'What is the id of the member you want to hackban?', - type: 'string' + type: 'string', + validate: id => { + if (/^[0-9]+$/.test(id)) return true; + return 'Invalid ID.'; + } }, { key: 'reason', prompt: 'What do you want to set the reason as?', type: 'string', - validate: reason => { - if (reason.length < 140) return true; - return 'Invalid reason, please keep the reason under 140 characters.'; - } + max: 140 } ] }); diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 2af3caf5..fc2175f7 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -23,10 +23,7 @@ module.exports = class KickCommand extends Command { key: 'reason', prompt: 'What do you want to set the reason as?', type: 'string', - validate: reason => { - if (reason.length < 140) return true; - return 'Invalid reason, please keep the reason under 140 characters.'; - } + max: 140 } ] }); diff --git a/commands/moderation/prune.js b/commands/moderation/prune.js index 43d3f9de..b1420b93 100644 --- a/commands/moderation/prune.js +++ b/commands/moderation/prune.js @@ -21,10 +21,8 @@ module.exports = class PruneCommand extends Command { label: 'amount of messages', prompt: 'How many messages do you want to delete? Limit of up to 99.', type: 'integer', - validate: count => { - if (count < 100 && count > 0) return true; - return 'Invalid count, please enter a number from 1-99.'; - } + min: 1, + max: 99 } ] }); diff --git a/commands/moderation/softban.js b/commands/moderation/softban.js index 50957dea..cece3c9f 100644 --- a/commands/moderation/softban.js +++ b/commands/moderation/softban.js @@ -23,10 +23,7 @@ module.exports = class SoftbanCommand extends Command { key: 'reason', prompt: 'What do you want to set the reason as?', type: 'string', - validate: reason => { - if (reason.length < 140) return true; - return 'Invalid reason, please keep the reason under 140 characters.'; - } + max: 140 } ] }); diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index ce7b326c..0a336d7a 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -16,16 +16,17 @@ module.exports = class UnbanCommand extends Command { { key: 'id', prompt: 'What is the id of the member you want to unban?', - type: 'string' + type: 'string', + validate: id => { + if (/^[0-9]+$/.test(id)) return true; + return 'Invalid ID.'; + } }, { key: 'reason', prompt: 'What do you want to set the reason as?', type: 'string', - validate: reason => { - if (reason.length < 140) return true; - return 'Invalid reason, please keep the reason under 140 characters.'; - } + max: 140 } ] }); diff --git a/commands/other/discriminator.js b/commands/other/discriminator.js index 0a8026ea..82615c10 100644 --- a/commands/other/discriminator.js +++ b/commands/other/discriminator.js @@ -13,10 +13,10 @@ module.exports = class DiscriminatorCommand extends Command { { key: 'discrim', prompt: 'Which discriminator would you like to search for?', - type: 'string', + type: 'integer', default: '', validate: discrim => { - if (/^[0-9]+$/g.test(discrim) && discrim.length === 4) return true; + if (/^[0-9]+$/.test(discrim) && discrim.length === 4) return true; return 'Invalid discriminator.'; } } diff --git a/commands/other/gender-guess.js b/commands/other/gender-guess.js index 911d92ad..9369bdb7 100644 --- a/commands/other/gender-guess.js +++ b/commands/other/gender-guess.js @@ -15,6 +15,7 @@ module.exports = class GenderGuessCommand extends Command { key: 'name', prompt: 'What name do you want to determine the gender of?', type: 'string', + max: 1950, parse: name => name.toLowerCase() } ] diff --git a/commands/other/google-doodle.js b/commands/other/google-doodle.js index 481ae742..acd6f1c1 100644 --- a/commands/other/google-doodle.js +++ b/commands/other/google-doodle.js @@ -15,10 +15,8 @@ module.exports = class GoogleDoodleCommand extends Command { prompt: 'What month would you like to get doodles for?', type: 'integer', default: 'latest', - validate: month => { - if (month < 13 && month > 0) return true; - return 'Invalid month, please enter a number from 1-12.'; - } + min: 1, + max: 12 }, { key: 'year', diff --git a/commands/other/lmgtfy.js b/commands/other/lmgtfy.js index 8de65746..05d1d960 100644 --- a/commands/other/lmgtfy.js +++ b/commands/other/lmgtfy.js @@ -13,6 +13,7 @@ module.exports = class LMGTFYCommand extends Command { key: 'query', prompt: 'What would you like the link to search for?', type: 'string', + max: 1950, parse: query => encodeURIComponent(query) } ] diff --git a/commands/other/strawpoll.js b/commands/other/strawpoll.js index 33f13d3c..1268f0c8 100644 --- a/commands/other/strawpoll.js +++ b/commands/other/strawpoll.js @@ -15,20 +15,14 @@ module.exports = class StrawpollCommand extends Command { key: 'title', prompt: 'What would you like the title of the Strawpoll to be?', type: 'string', - validate: title => { - if (title.length < 200) return true; - return 'Invalid title, please keep the title under 200 characters.'; - } + max: 200 }, { key: 'options', prompt: 'What options do you want to be able to pick from? You may have a maximum of 30.', type: 'string', infinite: true, - validate: choice => { - if (choice.length < 140) return true; - return 'Invalid option, please keep options under 140 characters each.'; - } + max: 140 } ] }); diff --git a/commands/random-res/8-ball.js b/commands/random-res/8-ball.js index 5171419d..05f3bf49 100644 --- a/commands/random-res/8-ball.js +++ b/commands/random-res/8-ball.js @@ -14,7 +14,8 @@ module.exports = class EightBallCommand extends Command { { key: 'question', prompt: 'What do you want to ask the 8 ball?', - type: 'string' + type: 'string', + max: 1950 } ] }); diff --git a/commands/random-res/charlie-charlie-challenge.js b/commands/random-res/charlie-charlie-challenge.js index 47c87703..6e321138 100644 --- a/commands/random-res/charlie-charlie-challenge.js +++ b/commands/random-res/charlie-charlie-challenge.js @@ -14,7 +14,8 @@ module.exports = class CharlieCharlieChallengeCommand extends Command { { key: 'question', prompt: 'What do you want to ask Charlie?', - type: 'string' + type: 'string', + max: 1950 } ] }); diff --git a/commands/random-res/choose.js b/commands/random-res/choose.js index 5752f8c4..78f67961 100644 --- a/commands/random-res/choose.js +++ b/commands/random-res/choose.js @@ -13,7 +13,8 @@ module.exports = class ChooseCommand extends Command { key: 'choices', prompt: 'What choices do you want me pick from?', type: 'string', - infinite: true + infinite: true, + max: 1950 } ] }); diff --git a/commands/random-res/kiss-marry-kill.js b/commands/random-res/kiss-marry-kill.js index 52a89b85..ed8a33d0 100644 --- a/commands/random-res/kiss-marry-kill.js +++ b/commands/random-res/kiss-marry-kill.js @@ -13,17 +13,20 @@ module.exports = class KissMarryKillCommand extends Command { { key: 'thing1', prompt: 'Who is the first person you choose?', - type: 'string' + type: 'string', + max: 500 }, { key: 'thing2', prompt: 'Who is the second person you choose?', - type: 'string' + type: 'string', + max: 500 }, { key: 'thing3', prompt: 'Who is the third person you choose?', - type: 'string' + type: 'string', + max: 500 } ] }); diff --git a/commands/random-res/magic-conch.js b/commands/random-res/magic-conch.js index 6f8dcd69..a3c5660e 100644 --- a/commands/random-res/magic-conch.js +++ b/commands/random-res/magic-conch.js @@ -14,7 +14,8 @@ module.exports = class MagicConchCommand extends Command { { key: 'question', prompt: 'What do you want to ask the magic conch?', - type: 'string' + type: 'string', + max: 1950 } ] }); diff --git a/commands/random-res/rate-waifu.js b/commands/random-res/rate-waifu.js index d471e304..b96ff594 100644 --- a/commands/random-res/rate-waifu.js +++ b/commands/random-res/rate-waifu.js @@ -4,7 +4,7 @@ module.exports = class RateWaifuCommand extends Command { constructor(client) { super(client, { name: 'rate-waifu', - aliases: ['waifu'], + aliases: ['waifu', 'rate'], group: 'random-res', memberName: 'rate-waifu', description: 'Rates your waifu.', @@ -12,7 +12,8 @@ module.exports = class RateWaifuCommand extends Command { { key: 'waifu', prompt: 'Who do you want to rate?', - type: 'string' + type: 'string', + max: 1950 } ] }); diff --git a/commands/random-res/ship.js b/commands/random-res/ship.js index f9432cf7..e14ea4ff 100644 --- a/commands/random-res/ship.js +++ b/commands/random-res/ship.js @@ -1,26 +1,30 @@ const { Command } = require('discord.js-commando'); -const { list } = require('../../util/Util'); module.exports = class ShipCommand extends Command { constructor(client) { super(client, { name: 'ship', - aliases: ['rate'], group: 'random-res', memberName: 'ship', description: 'Ships things/people together.', args: [ { - key: 'things', - prompt: 'What do you want to ship together?', + key: 'thing1', + prompt: 'Who is the first person in the ship?', type: 'string', - infinite: true + max: 500 + }, + { + key: 'thing2', + prompt: 'Who is the second person in the ship?', + type: 'string', + max: 500 } ] }); } - run(msg, { things }) { - return msg.say(`I'd give ${list(things)} a ${Math.floor(Math.random() * 100) + 1}%!`); + run(msg, { thing1, thing2 }) { + return msg.say(`I'd give ${thing1} and ${thing2} a ${Math.floor(Math.random() * 100) + 1}%!`); } }; diff --git a/commands/search/danbooru.js b/commands/search/danbooru.js index 624634aa..f5b8e956 100644 --- a/commands/search/danbooru.js +++ b/commands/search/danbooru.js @@ -9,6 +9,7 @@ module.exports = class DanbooruCommand extends Command { group: 'search', memberName: 'danbooru', description: 'Searches Danbooru for your query.', + nsfw: true, args: [ { key: 'query', @@ -24,7 +25,6 @@ module.exports = class DanbooruCommand extends Command { } async run(msg, { query }) { - if (!msg.channel.nsfw) return msg.reply('This command can only be used in NSFW channels.'); try { const { body } = await snekfetch .get('https://danbooru.donmai.us/posts.json') diff --git a/commands/search/gelbooru.js b/commands/search/gelbooru.js index f43e9020..398e1ee0 100644 --- a/commands/search/gelbooru.js +++ b/commands/search/gelbooru.js @@ -12,6 +12,7 @@ module.exports = class GelbooruCommand extends Command { group: 'search', memberName: 'gelbooru', description: 'Searches Gelbooru for your query.', + nsfw: true, args: [ { key: 'query', @@ -23,7 +24,6 @@ module.exports = class GelbooruCommand extends Command { } async run(msg, { query }) { - if (!msg.channel.nsfw) return msg.reply('This command can only be used in NSFW channels.'); try { const { text } = await snekfetch .get('https://gelbooru.com/index.php') diff --git a/commands/search/konachan.js b/commands/search/konachan.js index 35678c9b..09f5f883 100644 --- a/commands/search/konachan.js +++ b/commands/search/konachan.js @@ -9,6 +9,7 @@ module.exports = class KonachanCommand extends Command { group: 'search', memberName: 'konachan', description: 'Searches Konachan for your query.', + nsfw: true, args: [ { key: 'query', @@ -20,7 +21,6 @@ module.exports = class KonachanCommand extends Command { } async run(msg, { query }) { - if (!msg.channel.nsfw) return msg.reply('This command can only be used in NSFW channels.'); try { const { body } = await snekfetch .get('https://konachan.net/post.json') diff --git a/commands/search/map.js b/commands/search/map.js index b3342538..687af88a 100644 --- a/commands/search/map.js +++ b/commands/search/map.js @@ -17,10 +17,8 @@ module.exports = class MapCommand extends Command { label: 'zoom level', prompt: 'What would you like the zoom level to be? Must be a number from 1-20.', type: 'integer', - validate: zoom => { - if (zoom < 21 && zoom > 0) return true; - return 'Invalid zoom level, please enter a zoom level from 1-20.'; - } + min: 1, + max: 20 }, { key: 'query', diff --git a/commands/search/what-3-words.js b/commands/search/what-3-words.js index 75761ba7..e908758a 100644 --- a/commands/search/what-3-words.js +++ b/commands/search/what-3-words.js @@ -17,10 +17,8 @@ module.exports = class What3WordsCommand extends Command { label: 'zoom level', prompt: 'What would you like the zoom level to be? Must be a number from 1-20.', type: 'integer', - validate: zoom => { - if (zoom < 21 && zoom > 0) return true; - return 'Invalid zoom level, please enter a zoom level from 1-20.'; - } + min: 1, + max: 20 }, { key: 'word1', diff --git a/commands/text-edit/cow-say.js b/commands/text-edit/cow-say.js index 80ea9dd8..9638455d 100644 --- a/commands/text-edit/cow-say.js +++ b/commands/text-edit/cow-say.js @@ -13,10 +13,7 @@ module.exports = class CowSayCommand extends Command { key: 'text', prompt: 'What text would you like the cow to say?', type: 'string', - validate: text => { - if (text.length < 1500) return true; - return 'Invalid text, please keep the text under 1500 characters.'; - } + max: 1500 } ] }); diff --git a/commands/text-edit/dec-talk.js b/commands/text-edit/dec-talk.js index 3bc2d028..2a6132e1 100644 --- a/commands/text-edit/dec-talk.js +++ b/commands/text-edit/dec-talk.js @@ -22,10 +22,7 @@ module.exports = class DECTalkCommand extends Command { key: 'text', prompt: 'What text do you want to convert to TTS?', type: 'string', - validate: text => { - if (text.length < 1000) return true; - return 'Invalid text, please keep the text under 1000 characters.'; - } + max: 1000 } ] }); diff --git a/commands/text-edit/mocking.js b/commands/text-edit/mocking.js index a0b49ec9..1c5431a5 100644 --- a/commands/text-edit/mocking.js +++ b/commands/text-edit/mocking.js @@ -14,10 +14,7 @@ module.exports = class MockingCommand extends Command { key: 'text', prompt: 'WHaT tEXt WoUlD yOu LiKE to COnvErt?', type: 'string', - validate: text => { - if (text.length < 1950) return true; - return 'Invalid text, please keep the text under 1950 characters.'; - }, + max: 1950, parse: text => text.toLowerCase().split('') } ] diff --git a/commands/text-edit/organization-xiii-name.js b/commands/text-edit/organization-xiii-name.js index 18fe4eea..b0235ba0 100644 --- a/commands/text-edit/organization-xiii-name.js +++ b/commands/text-edit/organization-xiii-name.js @@ -14,6 +14,7 @@ module.exports = class OrganizationXIIINameCommand extends Command { key: 'text', prompt: 'What name would you like to convert?', type: 'string', + max: 1950, parse: text => text.toLowerCase().split('') } ] diff --git a/commands/text-edit/portal-send.js b/commands/text-edit/portal-send.js index 452bd7a9..4374a1c0 100644 --- a/commands/text-edit/portal-send.js +++ b/commands/text-edit/portal-send.js @@ -14,17 +14,14 @@ module.exports = class PortalSendCommand extends Command { key: 'text', prompt: 'What text would you like to send?', type: 'string', - validate: text => { - if (/discord(\.gg|app\.com\/invite|\.me)\//gi.test(text)) return 'Please do not send invites.'; - if (text.length < 1000) return true; - return 'Invalid text, please keep the text under 1000 characters.'; - } + max: 1000 } ] }); } async run(msg, { text }) { + if (/discord(\.gg|app\.com\/invite|\.me)\//gi.test(text)) return msg.reply('Please do not send invites.'); const valid = this.client.channels.filter(channel => channel.type === 'text' && channel.guild.id !== msg.guild.id); const channels = valid.filter(channel => channel.topic && channel.topic.toLowerCase().includes('')); if (!channels.size) return msg.say('No channels have an open portal.'); diff --git a/commands/text-edit/repeat.js b/commands/text-edit/repeat.js index e69e5f7f..ea8284db 100644 --- a/commands/text-edit/repeat.js +++ b/commands/text-edit/repeat.js @@ -8,6 +8,13 @@ module.exports = class RepeatCommand extends Command { memberName: 'repeat', description: 'Repeat text over and over and over and over (etc).', args: [ + { + key: 'amount', + prompt: 'How many times do you want to repeat your text?', + type: 'integer', + min: 1, + max: 2000 + }, { key: 'text', prompt: 'What text would you like to repeat over and over and over and over?', @@ -21,7 +28,7 @@ module.exports = class RepeatCommand extends Command { }); } - run(msg, { text }) { - return msg.say(text.repeat(2000).substr(0, 2000)); + run(msg, { amount, text }) { + return msg.say(text.repeat(amount).substr(0, 2000)); } }; diff --git a/commands/text-edit/say.js b/commands/text-edit/say.js index ad7f571b..5a9eac7c 100644 --- a/commands/text-edit/say.js +++ b/commands/text-edit/say.js @@ -12,7 +12,11 @@ module.exports = class SayCommand extends Command { { key: 'text', prompt: 'What text would you like XiaoBot to say?', - type: 'string' + type: 'string', + validate: text => { + if (!text.includes('@everyone') && !text.includes('@here')) return true; + return 'Invalid text, please do not say everyone or here mentions.'; + } } ] }); diff --git a/commands/text-edit/ship-name.js b/commands/text-edit/ship-name.js index bf436217..610028d7 100644 --- a/commands/text-edit/ship-name.js +++ b/commands/text-edit/ship-name.js @@ -13,10 +13,7 @@ module.exports = class ShipNameCommand extends Command { label: 'start name', prompt: 'What name should be at the start of the ship name?', type: 'string', - validate: start => { - if (start.length < 50) return true; - return 'Invalid start name, the start name must be under 50 characters.'; - }, + max: 500, parse: start => start.toLowerCase() }, { @@ -24,10 +21,7 @@ module.exports = class ShipNameCommand extends Command { label: 'end name', prompt: 'What name should be at the end of the ship name?', type: 'string', - validate: end => { - if (end.length < 50) return true; - return 'Invalid end name, the end name must be under 50 characters.'; - }, + max: 500, parse: end => end.toLowerCase() } ] diff --git a/commands/text-edit/translate.js b/commands/text-edit/translate.js index 69251505..e49f9017 100644 --- a/commands/text-edit/translate.js +++ b/commands/text-edit/translate.js @@ -20,10 +20,7 @@ module.exports = class TranslateCommand extends Command { key: 'text', prompt: 'What text would you like to translate?', type: 'string', - validate: text => { - if (text.length < 500) return true; - return 'Invalid text, please keep the text under 500 characters.'; - } + max: 500 }, { key: 'target', diff --git a/commands/text-edit/yoda.js b/commands/text-edit/yoda.js index 90215a77..b91e603b 100644 --- a/commands/text-edit/yoda.js +++ b/commands/text-edit/yoda.js @@ -15,10 +15,7 @@ module.exports = class YodaCommand extends Command { key: 'sentence', prompt: 'What sentence would you like to convert to Yoda speak?', type: 'string', - validate: sentence => { - if (sentence.length < 500) return true; - return 'Invalid sentence, please keep the sentence under 500 characters.'; - } + max: 500 } ] }); diff --git a/commands/text-edit/zalgo.js b/commands/text-edit/zalgo.js index f97917e6..aa34f794 100644 --- a/commands/text-edit/zalgo.js +++ b/commands/text-edit/zalgo.js @@ -14,10 +14,7 @@ module.exports = class ZalgoCommand extends Command { key: 'text', prompt: 'What text would you like to convert to zalgo?', type: 'string', - validate: text => { - if (text.length < 200) return true; - return 'Invalid text, please keep the text under 200 characters.'; - } + max: 200 } ] }); diff --git a/package.json b/package.json index e72f1ac6..e00664a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "51.3.0", + "version": "51.3.1", "description": "Your personal server companion.", "main": "XiaoBot.js", "scripts": {