diff --git a/README.md b/README.md index e182ceed..2f5adb80 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You can invite the bot to your server using Be sure to also join the [home server](https://discord.gg/sbMe32W) for information and support. -## Commands (289) +## Commands (290) ### Utility: * **prefix**: Shows or sets the command prefix. @@ -281,6 +281,7 @@ information and support. * **braille**: Converts text to braille. * **clap**: Sends 👏 text 👏 like 👏 this. * **cow-say**: Makes a cow say your text. +* **cow-think**: Makes a cow think your text. * **cursive**: Converts text to cursive. * **dvorak**: Converts text to Dvorak encoding. * **embed**: Sends text in an embed. diff --git a/commands/text-edit/cow-say.js b/commands/text-edit/cow-say.js index 9a56b4a6..d79fe0be 100644 --- a/commands/text-edit/cow-say.js +++ b/commands/text-edit/cow-say.js @@ -1,5 +1,9 @@ const Command = require('../../structures/Command'); -const request = require('node-superfetch'); +const cowsay = require('cowsay'); +const cowList = require('cowsay/lib/cows'); +const { list } = require('../../util/Util'); +const cows = cowList.listSync(); +cows.push('random'); module.exports = class CowSayCommand extends Command { constructor(client) { @@ -8,28 +12,37 @@ module.exports = class CowSayCommand extends Command { group: 'text-edit', memberName: 'cow-say', description: 'Makes a cow say your text.', + details: `**Types**: ${cows.join(', ')}`, args: [ { key: 'text', prompt: 'What text would you like the cow to say?', type: 'string', max: 1500 + }, + { + key: 'type', + prompt: `What type of cow would you like to use? Either ${list(cows, 'or')}.`, + type: 'string', + default: 'default', + validate: type => { + if (cows.includes(type.toLowerCase()) || type.toLowerCase() === 'cow') return true; + return `Invalid type, please enter either ${list(cows, 'or')}.`; + }, + parse: type => { + if (type.toLowerCase() === 'cow') return 'default'; + return type.toLowerCase(); + } } ] }); } - async run(msg, { text }) { - try { - const { body } = await request - .get('http://cowsay.morecode.org/say') - .query({ - message: text, - format: 'json' - }); - return msg.code(null, body.cow); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } + run(msg, { text, type }) { + return msg.code(null, cowsay.say({ + text, + f: type, + r: type === 'random' + })); } }; diff --git a/commands/text-edit/cow-think.js b/commands/text-edit/cow-think.js new file mode 100644 index 00000000..7d16d627 --- /dev/null +++ b/commands/text-edit/cow-think.js @@ -0,0 +1,48 @@ +const Command = require('../../structures/Command'); +const cowsay = require('cowsay'); +const cowList = require('cowsay/lib/cows'); +const { list } = require('../../util/Util'); +const cows = cowList.listSync(); +cows.push('random'); + +module.exports = class CowThinkCommand extends Command { + constructor(client) { + super(client, { + name: 'cow-think', + group: 'text-edit', + memberName: 'cow-think', + description: 'Makes a cow think your text.', + details: `**Types**: ${cows.join(', ')}`, + args: [ + { + key: 'text', + prompt: 'What text would you like the cow to think?', + type: 'string', + max: 1500 + }, + { + key: 'type', + prompt: `What type of cow would you like to use? Either ${list(cows, 'or')}.`, + type: 'string', + default: 'default', + validate: type => { + if (cows.includes(type.toLowerCase()) || type.toLowerCase() === 'cow') return true; + return `Invalid type, please enter either ${list(cows, 'or')}.`; + }, + parse: type => { + if (type.toLowerCase() === 'cow') return 'default'; + return type.toLowerCase(); + } + } + ] + }); + } + + run(msg, { text, type }) { + return msg.code(null, cowsay.think({ + text, + f: type, + r: type === 'random' + })); + } +}; diff --git a/package.json b/package.json index a0a2b7b1..7e2b01ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "83.1.0", + "version": "84.0.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { @@ -33,6 +33,7 @@ "dependencies": { "canvas": "github:automattic/node-canvas", "common-tags": "^1.8.0", + "cowsay": "^1.3.1", "custom-translate": "^2.2.4", "discord.js": "github:discordjs/discord.js", "discord.js-commando": "github:discordjs/Commando",