diff --git a/README.md b/README.md index 645159c9..71bba73d 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ served over 10,000 servers with a uniquely devoted fanbase. * **morse**: Converts text to morse code. * **organization-xiii-name**: Converts a name into the Organization XIII style. * **owo**: OwO. +* **pig-latin**: Converts text to pig latin. * **pirate**: Converts text to pirate. * **qr-code**: Converts text to a QR Code. * **repeat**: Repeat text over and over and over and over (etc). diff --git a/commands/text-edit/pig-latin.js b/commands/text-edit/pig-latin.js new file mode 100644 index 00000000..a0b86c16 --- /dev/null +++ b/commands/text-edit/pig-latin.js @@ -0,0 +1,35 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class PigLatinCommand extends Command { + constructor(client) { + super(client, { + name: 'pig-latin', + group: 'text-edit', + memberName: 'pig-latin', + description: 'Converts text to pig latin.', + args: [ + { + key: 'text', + prompt: 'What text would you like to convert to pig latin?', + type: 'string', + validate: text => { + if (this.pigLatin(text).length < 2000) return true; + return 'Invalid text, your text is too long.'; + } + } + ] + }); + } + + run(msg, { text }) { + return msg.say(this.pigLatin(text)); + } + + pigLatin(text) { + return text.replace(/\w+/g, this.pigLatinWord).toLowerCase(); + } + + pigLatinWord(word) { + return `${word.slice(1)}${word.charAt(0)}ay`; + } +}; diff --git a/package.json b/package.json index 110e2123..5d7e3db6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "69.0.1", + "version": "69.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {