mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 06:37:32 +02:00
Fix all audio commands
This commit is contained in:
@@ -38,12 +38,12 @@ module.exports = class PlayCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
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.');
|
||||
const result = await this.searchForVideo(query, msg.channel.nsfw || false);
|
||||
if (!result) return msg.reply('Could not find any results for your query.');
|
||||
const data = await ytdl.getInfo(result);
|
||||
@@ -55,10 +55,7 @@ module.exports = class PlayCommand extends Command {
|
||||
});
|
||||
const verification = await verify(msg.channel, msg.author);
|
||||
if (!verification) return msg.reply('Aborting playback.');
|
||||
const dispatcher = connection.play(ytdl(result, { filter: 'audioonly' }));
|
||||
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(ytdl(result, { filter: 'audioonly' }));
|
||||
return msg.reply(`🔉 Now playing **${shorten(data.videoDetails.title, 70)}**!`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user