mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
Fix all audio commands
This commit is contained in:
@@ -56,17 +56,14 @@ module.exports = class PokedexCryCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { pokemon }) {
|
||||
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 {
|
||||
const dispatcher = connection.play(pokemon.cry);
|
||||
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(pokemon.cry);
|
||||
await reactIfAble(msg, this.client.user, '🔉');
|
||||
return null;
|
||||
} catch (err) {
|
||||
|
||||
@@ -113,12 +113,9 @@ module.exports = class PokedexCommand extends Command {
|
||||
? 'Genderless'
|
||||
: `♂️ ${pokemon.genderRate.male}% ♀️ ${pokemon.genderRate.female}%`);
|
||||
if (msg.guild && pokemon.cry && !this.client.dispatchers.has(msg.guild.id)) {
|
||||
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
|
||||
const connection = msg.guild ? this.client.dispatchers.get(msg.guild.id) : null;
|
||||
if (connection) {
|
||||
const dispatcher = connection.play(pokemon.cry);
|
||||
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(pokemon.cry);
|
||||
await reactIfAble(msg, this.client.user, '🔉');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user