mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Lock/Unlock for Voice Dispatchers
This commit is contained in:
@@ -41,6 +41,7 @@ module.exports = class HearingTestCommand extends Command {
|
||||
let range;
|
||||
let previousAge = 'all';
|
||||
let previousRange = 8;
|
||||
connection.lock();
|
||||
const gameMsg = await msg.say('Here\'s the first sound. Listen carefully!');
|
||||
let buttonPress;
|
||||
for (const { age: dataAge, khz, file } of data) {
|
||||
@@ -79,6 +80,7 @@ module.exports = class HearingTestCommand extends Command {
|
||||
components: []
|
||||
});
|
||||
}
|
||||
connection.unlock();
|
||||
if (age === 'all') {
|
||||
return gameMsg.edit({
|
||||
content: 'Everyone should be able to hear that. You cannot hear.',
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "151.2.0",
|
||||
"version": "151.2.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"private": true,
|
||||
|
||||
@@ -5,6 +5,7 @@ module.exports = class VoiceDispatcher {
|
||||
this.channel = channel;
|
||||
this.player = createAudioPlayer();
|
||||
getVoiceConnection(channel.guild.id).subscribe(this.player);
|
||||
this.locked = false;
|
||||
}
|
||||
|
||||
play(content) {
|
||||
@@ -33,6 +34,16 @@ module.exports = class VoiceDispatcher {
|
||||
return this.player.unpause();
|
||||
}
|
||||
|
||||
lock() {
|
||||
this.locked = true;
|
||||
return this.locked;
|
||||
}
|
||||
|
||||
unlock() {
|
||||
this.locked = false;
|
||||
return this.locked;
|
||||
}
|
||||
|
||||
get connection() {
|
||||
return getVoiceConnection(this.guild.id);
|
||||
}
|
||||
@@ -46,6 +57,6 @@ module.exports = class VoiceDispatcher {
|
||||
}
|
||||
|
||||
get canPlay() {
|
||||
return this.player.state.status === AudioPlayerStatus.Idle;
|
||||
return this.player.state.status === AudioPlayerStatus.Idle && !this.locked;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user