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