Fix all audio commands

This commit is contained in:
Dragon Fire
2024-03-20 16:42:17 -04:00
parent e09d761463
commit bd6fe1d4d7
16 changed files with 48 additions and 95 deletions
+3 -6
View File
@@ -47,19 +47,16 @@ module.exports = class DECTalkCommand extends Command {
}
async run(msg, { text }) {
const connection = this.client.voice.connections.get(msg.guild.id);
const connection = this.client.dispatchers.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!`);
}
if (this.client.dispatchers.has(msg.guild.id)) return msg.reply('I am already playing audio in this server.');
if (!connection.canPlay) return msg.reply('I am already playing audio in this server.');
try {
await reactIfAble(msg, this.client.user, LOADING_EMOJI_ID, '💬');
const body = await this.tts(msg.guild.id, text);
const dispatcher = connection.play(Readable.from([body]));
this.client.dispatchers.set(msg.guild.id, dispatcher);
dispatcher.once('finish', () => this.client.dispatchers.delete(msg.guild.id));
dispatcher.once('error', () => this.client.dispatchers.delete(msg.guild.id));
connection.play(Readable.from([body]));
await reactIfAble(msg, this.client.user, '🔉');
return null;
} catch (err) {