diff --git a/README.md b/README.md index dcdd1190..f59aa3aa 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 409 +Total: 410 ### Utility: @@ -513,6 +513,7 @@ Total: 409 * **clap:** Sends 👏 text 👏 like 👏 this. * **cow-say:** Makes a cow say your text. * **cursive:** Converts text to cursive. +* **dec-talk:** The world's best Text-to-Speech. * **dvorak:** Converts text to Dvorak encoding. * **embed:** Sends text in an embed. * **emojify:** Converts text to emoji form. @@ -688,6 +689,8 @@ here. * bulbapedia ([API](https://bulbapedia.bulbagarden.net/w/api.php)) - [Bulletin of the Atomic Scientists](https://thebulletin.org/) * doomsday-clock ([Doomsday Clock Data](https://thebulletin.org/doomsday-clock/current-time/)) +- [calzoneman](https://github.com/calzoneman) + * dec-talk ([API](https://github.com/calzoneman/aeiou)) - [Capcom](http://www.capcom.com/us/) * ace-attorney ([Images, Original "Ace Attorney" Game](http://www.ace-attorney.com/)) * zero-dialogue ([Image, Original "Megaman Zero" Game](http://megaman.capcom.com/)) @@ -728,6 +731,8 @@ here. * deviantart ([API](https://www.deviantart.com/developers/)) - [devsnek](https://github.com/devsnek) * owo (Code) +- [Digital Equipment Corporation](http://gordonbell.azurewebsites.net/digital/timeline/tmlnhome.htm) + * dec-talk (Original DECTalk Software) - [Discord Status Button](https://discord.c99.nl/) * status-button (API) - [Disney](https://www.disney.com/) @@ -973,6 +978,7 @@ here. * doors (Concept) - [NASA](https://www.nasa.gov/) * apod ([APOD API](https://api.nasa.gov/)) + * dec-talk ([Original "Moonbase Alpha" Game](https://store.steampowered.com/app/39000/Moonbase_Alpha/)) * gravity ([Planet Gravity Data](https://nssdc.gsfc.nasa.gov/planetary/factsheet/planet_table_ratio.html)) * nasa ([NASA Image and Video Library API](https://api.nasa.gov/)) - [National Suicide Prevention Lifeline](https://suicidepreventionlifeline.org/) diff --git a/commands/edit-text/dec-talk.js b/commands/edit-text/dec-talk.js new file mode 100644 index 00000000..6bb64f31 --- /dev/null +++ b/commands/edit-text/dec-talk.js @@ -0,0 +1,72 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); + +module.exports = class DECTalkCommand extends Command { + constructor(client) { + super(client, { + name: 'dec-talk', + aliases: ['text-to-speech', 'tts'], + group: 'edit-text', + memberName: 'dec-talk', + description: 'The world\'s best Text-to-Speech.', + guildOnly: true, + throttling: { + usages: 1, + duration: 10 + }, + userPermissions: ['CONNECT', 'SPEAK'], + clientPermissions: ['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'], + credit: [ + { + name: 'calzoneman', + url: 'https://github.com/calzoneman', + reason: 'API', + reasonURL: 'https://github.com/calzoneman/aeiou' + }, + { + name: 'Digital Equipment Corporation', + url: 'http://gordonbell.azurewebsites.net/digital/timeline/tmlnhome.htm', + reason: 'Original DECTalk Software' + }, + { + name: 'NASA', + url: 'https://www.nasa.gov/', + reason: 'Original "Moonbase Alpha" Game', + reasonURL: 'https://store.steampowered.com/app/39000/Moonbase_Alpha/' + } + ], + args: [ + { + key: 'text', + prompt: 'What text do you want to say?', + type: 'string', + max: 1024 + } + ] + }); + } + + async run(msg, { text }) { + const voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.say('Please enter a voice channel first.'); + if (!voiceChannel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK'])) { + return msg.say('Missing the "Connect" or "Speak" permission for the voice channel.'); + } + if (!voiceChannel.joinable) return msg.say('Your voice channel is not joinable.'); + if (this.client.voiceConnections.has(voiceChannel.guild.id)) return msg.say('I am already playing a sound.'); + try { + const connection = await voiceChannel.join(); + const { url } = await request + .get('http://tts.cyzon.us/tts') + .query({ text }); + const dispatcher = connection.play(url); + await msg.react('🔉'); + dispatcher.once('finish', () => voiceChannel.leave()); + dispatcher.once('error', () => voiceChannel.leave()); + return null; + } catch (err) { + voiceChannel.leave(); + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index acd1ca8c..771d5b43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.2.1", + "version": "114.3.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { @@ -32,6 +32,7 @@ }, "dependencies": { "@discordjs/collection": "^0.1.5", + "@discordjs/opus": "^0.3.2", "@vitalets/google-translate-api": "^3.0.0", "canvas": "^2.6.1", "cheerio": "^1.0.0-rc.3", @@ -43,7 +44,7 @@ "discord.js-commando": "github:discordjs/Commando", "dotenv": "^8.2.0", "gifencoder": "^2.0.1", - "mathjs": "^6.6.4", + "mathjs": "^6.6.5", "moment": "^2.25.3", "moment-duration-format": "^2.3.2", "moment-timezone": "^0.5.28",