diff --git a/commands/imageedit/meme.js b/commands/imageedit/meme.js index 3db2f89d..32b865a7 100644 --- a/commands/imageedit/meme.js +++ b/commands/imageedit/meme.js @@ -10,9 +10,9 @@ module.exports = class MemeCommand extends Command { ], group: 'imageedit', memberName: 'meme', - description: 'Sends a Meme with text of your choice, and a background of your choice. Split first and second lines with a | (;meme facepalm I can\'t even | comprehend this)', + description: 'Sends a Meme with text of your choice, and a background of your choice. (;meme facepalm "I can\'t even" "comprehend this")', details: '**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', - examples: [';meme facepalm I can\'t even | comprehend this'], + examples: [';meme facepalm "I can\'t even" "comprehend this"'], args: [{ key: 'type', prompt: 'What meme type do you want to use?', @@ -24,14 +24,24 @@ module.exports = class MemeCommand extends Command { return 'Please enter a valid meme type. Use `;help meme` to view a list of types.'; } }, { - key: 'content', - prompt: 'What should the meme content be? Split the bottom and top text of the meme with " | ".', + key: 'toprow', + prompt: 'What should the top row of the meme to be? Surround in "" for multiple words.', type: 'string', - validate: content => { - if (content.includes(' | ') && content.match(/^[a-zA-Z0-9|.,!?'-\s]+$/)) { + validate: toprow => { + if (toprow.match(/^[a-zA-Z0-9|.,!?'-\s]+$/) && toprow.length < 101) { return true; } - return 'Please split your choices with ' | ' and do not use special characters.'; + return 'Please do not use special characters and keep the rows under 100 characters each.'; + } + }, { + key: 'bottomrow', + prompt: 'What should the bottom row of the meme to be? Surround in "" for multiple words.', + type: 'string', + validate: bottomrow => { + if (bottomrow.match(/^[a-zA-Z0-9|.,!?'-\s]+$/) && bottomrow.length < 101) { + return true; + } + return 'Please do not use special characters and keep the rows under 100 characters each.'; } }] }); @@ -43,13 +53,9 @@ module.exports = class MemeCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } const type = args.type.toLowerCase(); - const content = args.content; - const memeQuery = content.split(' ').join('-').split('-|-'); - const toprow = memeQuery[0].split('?').join('~q'); - const bottomrow = memeQuery[1].split('?').join('~q'); + const toprow = args.toprow.split(' ').join('-').split('?').join('~q'); + const bottomrow = args.bottomrow.split(' ').join('-').split('?').join('~q'); const link = `https://memegen.link/${type}/${toprow}/${bottomrow}.jpg`; - if (bottomrow.length > 100) return message.say(':x: Error! Bottom text is over 100 characters!'); - if (toprow.length > 100) return message.say(':x: Error! Top text is over 100 characters!'); - return message.channel.sendFile(link).catch(err => message.say(':x: Error! Something went wrong!')); + return message.channel.sendFile(link).catch(() => message.say(':x: Error! Something went wrong!')); } }; diff --git a/commands/random/strawpoll.js b/commands/random/strawpoll.js index 56146b96..74fc93eb 100644 --- a/commands/random/strawpoll.js +++ b/commands/random/strawpoll.js @@ -11,8 +11,8 @@ module.exports = class StrawpollCommand extends Command { ], group: 'random', memberName: 'strawpoll', - description: 'Creates a Strawpoll with your options. (;strawpoll "Who likes chips?" Me | Not Me)', - examples: [';strawpoll "Who likes chips?" Me | Not Me'], + description: 'Creates a Strawpoll with your options. (;strawpoll "Who likes chips?" "Me" "Not Me")', + examples: [';strawpoll "Who likes chips?" "Me" "Not Me"'], args: [{ key: 'title', prompt: 'What would you like the title of the Strawpoll to be? Surround in "" for multiple words.', @@ -25,17 +25,9 @@ module.exports = class StrawpollCommand extends Command { } }, { key: 'choices', - prompt: 'What choices do you want me pick from? Split them with " | ".', + prompt: 'What choices do you want me pick from? Surround each choice in "".', type: 'string', - validate: content => { - if (content.includes(' | ')) { - return true; - } - if (content.length > 160) { - return 'Please limit your options to 160 characters.'; - } - return 'Please split your choices with ' | '.'; - } + infinite: true }] }); } diff --git a/commands/response/choose.js b/commands/response/choose.js index 93287b9b..eb14248d 100644 --- a/commands/response/choose.js +++ b/commands/response/choose.js @@ -9,18 +9,13 @@ module.exports = class ChooseCommand extends Command { ], group: 'response', memberName: 'choose', - description: 'Chooses between things. (;choose Cow | Sheep)', - examples: [';choose Cow | Sheep', ';choose Bark | Woof | Meow | Moo'], + description: 'Chooses between things. (;choose "Cow" "Sheep")', + examples: [';choose "Cow" "Sheep"', ';choose "Bark" "Woof" "Meow" "Moo"'], args: [{ key: 'choices', - prompt: 'What choices do you want me pick from? Split them with " | ".', + prompt: 'What choices do you want me pick from? Surround each choice in "".', type: 'string', - validate: content => { - if (content.includes(' | ')) { - return true; - } - return 'Please split your choices with ' | '.'; - } + infinite: true }] }); } @@ -30,7 +25,6 @@ module.exports = class ChooseCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } let choices = args.choices; - choices = choices.split(' | '); choices = choices[Math.floor(Math.random() * choices.length)]; return message.say(`I choose ${choices}!`); } diff --git a/index.js b/index.js index 20b26976..e1acfb81 100644 --- a/index.js +++ b/index.js @@ -27,7 +27,8 @@ client.registry ]) .registerDefaultGroups() .registerDefaultCommands({ - prefix: false + prefix: false, + commandState: false }) .registerCommandsIn(path.join(__dirname, 'commands')); diff --git a/package.json b/package.json index 90537665..a03a27fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "22.1.0", + "version": "22.2.0", "description": "A Discord Bot", "main": "shardingmanager.js", "repository": { diff --git a/types/array.js b/types/array.js new file mode 100644 index 00000000..5faeb44f --- /dev/null +++ b/types/array.js @@ -0,0 +1,40 @@ +const { ArgumentType } = require('discord.js-commando'); +const emojiRanges = [ + '[\u0023-\u0039]\u20E3', + '[\u2002-\u21AA]', + '[\u231A-\u27bf]', + '[\u2934-\u2b55]', + '\u3030', '\u303D', + '\u3297', '\u3299', + '\uD83C[\udc04-\uDFFF]', + '\uD83D[\uDC00-\uDE4F]' +]; +const emojiRegex = new RegExp(emojiRanges.join('|'), 'g'); +const regex = /<:([a-zA-Z0-9_]+):(\d+)>/; + +class EmojiArgumentType extends ArgumentType { + constructor(client) { + super(client, 'emoji'); + } + + validate(value, msg) { + if (value.match(regex)) { + const emoji = msg.client.emojis.get(value.match(regex)[2]); + if (emoji) return true; + } else if (value.match(emojiRegex)) { + return true; + } + return false; + } + + parse(value, msg) { // eslint-disable-line consistent-return + if (value.match(regex)) { + const emoji = msg.client.emojis.get(value.match(regex)[2]); + if (emoji) return emoji; + } else if (value.match(emojiRegex)) { + return value.match(emojiRegex)[0]; + } + } +} + +module.exports = EmojiArgumentType; \ No newline at end of file