mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Fix voice channel
This commit is contained in:
@@ -26,24 +26,24 @@ module.exports = class DECTalkCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { text }) {
|
||||
const channel = msg.member.voiceChannel;
|
||||
if (!channel) return msg.say('Please enter a voice channel first.');
|
||||
if (!channel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK'])) {
|
||||
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 (!channel.joinable) return msg.say('Your voice channel is not joinable.');
|
||||
if (this.client.voiceConnections.has(channel.guild.id)) return msg.say('I am already playing a sound.');
|
||||
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 channel.join();
|
||||
const connection = await voiceChannel.join();
|
||||
const { url } = await request
|
||||
.get('http://tts.cyzon.us/tts')
|
||||
.query({ text });
|
||||
const dispatcher = connection.play(url);
|
||||
dispatcher.once('finish', () => channel.leave());
|
||||
dispatcher.once('error', () => channel.leave());
|
||||
dispatcher.once('finish', () => voiceChannel.leave());
|
||||
dispatcher.once('error', () => voiceChannel.leave());
|
||||
return null;
|
||||
} catch (err) {
|
||||
channel.leave();
|
||||
voiceChannel.leave();
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,21 +33,21 @@ module.exports = class SoundboardCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { sound }) {
|
||||
const channel = msg.member.voiceChannel;
|
||||
if (!channel) return msg.reply('Please enter a voice channel first.');
|
||||
if (!channel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK'])) {
|
||||
const voiceChannel = msg.member.voice.channel;
|
||||
if (!voiceChannel) return msg.reply('Please enter a voice channel first.');
|
||||
if (!voiceChannel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK'])) {
|
||||
return msg.reply('Missing the "Connect" or "Speak" permission for the voice channel.');
|
||||
}
|
||||
if (!channel.joinable) return msg.reply('Your voice channel is not joinable.');
|
||||
if (this.client.voiceConnections.has(channel.guild.id)) return msg.reply('I am already playing a sound.');
|
||||
if (!voiceChannel.joinable) return msg.reply('Your voice channel is not joinable.');
|
||||
if (this.client.voiceConnections.has(voiceChannel.guild.id)) return msg.reply('I am already playing a sound.');
|
||||
try {
|
||||
const connection = await channel.join();
|
||||
const connection = await voiceChannel.join();
|
||||
const dispatcher = connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', sounds[sound]));
|
||||
dispatcher.once('finish', () => channel.leave());
|
||||
dispatcher.once('error', () => channel.leave());
|
||||
dispatcher.once('finish', () => voiceChannel.leave());
|
||||
dispatcher.once('error', () => voiceChannel.leave());
|
||||
return null;
|
||||
} catch (err) {
|
||||
channel.leave();
|
||||
voiceChannel.leave();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user