mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Vocodes Command
This commit is contained in:
@@ -257,7 +257,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 551
|
||||
Total: 552
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -824,6 +824,7 @@ Total: 551
|
||||
* **join:** Joins your voice channel.
|
||||
* **leave:** Leaves the current voice channel.
|
||||
* **soundboard:** Plays a sound in a voice channel.
|
||||
* **vocodes:** Speak text like a variety of famous figures.
|
||||
|
||||
### Phone:
|
||||
|
||||
@@ -1722,6 +1723,8 @@ here.
|
||||
* rip ([Image](https://www.123rf.com/profile_vician?mediapopup=13181623))
|
||||
- [VocaDB](https://vocadb.net/)
|
||||
* vocadb ([API](https://vocadb.net/swagger/ui/index))
|
||||
- [Vocodes](https://vo.codes/)
|
||||
* vocodes (API)
|
||||
- [Wait, what does your startup do?](http://itsthisforthat.com/)
|
||||
* this-for-that ([API](http://itsthisforthat.com/api.php))
|
||||
- [WAIT: What Anime Is This?](https://trace.moe/)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { Readable } = require('stream');
|
||||
const { list } = require('../../util/Util');
|
||||
const voices = {
|
||||
sonic: 'sonic',
|
||||
homer: 'homer-simpson',
|
||||
spongebob: 'spongebob-squarepants',
|
||||
arnold: 'arnold-schwarzenegger'
|
||||
};
|
||||
|
||||
module.exports = class VocodesCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'vocodes',
|
||||
group: 'voice',
|
||||
memberName: 'vocodes',
|
||||
description: 'Speak text like a variety of famous figures.',
|
||||
guildOnly: true,
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
userPermissions: ['CONNECT', 'SPEAK'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Vocodes',
|
||||
url: 'https://vo.codes/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'voice',
|
||||
prompt: `What voice do you want to use? Either ${list(Object.keys(voices), 'or')}.`,
|
||||
type: 'string',
|
||||
oneOf: Object.keys(voices),
|
||||
parse: voice => voices[voice.toLowerCase()]
|
||||
},
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What text do you want to say?',
|
||||
type: 'string',
|
||||
max: 500
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { voice, text }) {
|
||||
const connection = this.client.voice.connections.get(msg.guild.id);
|
||||
if (!connection) {
|
||||
const usage = this.client.registry.commands.get('join').usage();
|
||||
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
||||
}
|
||||
try {
|
||||
const body = await request
|
||||
.post('https://mumble.stream/speak_spectrogram')
|
||||
.send({
|
||||
speaker: voice,
|
||||
text
|
||||
});
|
||||
connection.play(Readable.from([Buffer.from(body.audio_base64, 'base64')]));
|
||||
if (msg.channel.permissionsFor(this.client.user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
||||
await msg.react('🔉');
|
||||
}
|
||||
return null;
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "119.33.1",
|
||||
"version": "119.34.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user