events
This commit is contained in:
parent
4990252701
commit
574c163f5b
3 changed files with 31 additions and 22 deletions
|
@ -69,28 +69,29 @@ class Player extends EventEmitter<PlayerEvents> {
|
|||
const queue = this.getQueue(oldState.guild.id);
|
||||
if (!queue) return;
|
||||
|
||||
// @todo
|
||||
// update channel
|
||||
if (oldState.channelID && newState.channelID && oldState.channelID !== newState.channelID) {
|
||||
queue.connection.channel = newState.channel;
|
||||
}
|
||||
// if (oldState.channelID && newState.channelID && oldState.channelID !== newState.channelID) {
|
||||
// queue.connection.channel = newState.channel;
|
||||
// }
|
||||
|
||||
if (!oldState.channelID && newState.channelID && newState.member.id === newState.guild.me.id) {
|
||||
if (newState.serverMute || !newState.serverMute) {
|
||||
queue.setPaused(newState.serverMute);
|
||||
} else if (newState.suppress || !newState.suppress) {
|
||||
if (newState.suppress) newState.guild.me.voice.setRequestToSpeak(true).catch(Util.noop);
|
||||
queue.setPaused(newState.suppress);
|
||||
}
|
||||
}
|
||||
// if (!oldState.channelID && newState.channelID && newState.member.id === newState.guild.me.id) {
|
||||
// if (newState.serverMute || !newState.serverMute) {
|
||||
// queue.setPaused(newState.serverMute);
|
||||
// } else if (newState.suppress || !newState.suppress) {
|
||||
// if (newState.suppress) newState.guild.me.voice.setRequestToSpeak(true).catch(Util.noop);
|
||||
// queue.setPaused(newState.suppress);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (oldState.channelID === newState.channelID && oldState.member.id === newState.guild.me.id) {
|
||||
if (oldState.serverMute !== newState.serverMute) {
|
||||
queue.setPaused(newState.serverMute);
|
||||
} else if (oldState.suppress !== newState.suppress) {
|
||||
if (newState.suppress) newState.guild.me.voice.setRequestToSpeak(true).catch(Util.noop);
|
||||
queue.setPaused(newState.suppress);
|
||||
}
|
||||
}
|
||||
// if (oldState.channelID === newState.channelID && oldState.member.id === newState.guild.me.id) {
|
||||
// if (oldState.serverMute !== newState.serverMute) {
|
||||
// queue.setPaused(newState.serverMute);
|
||||
// } else if (oldState.suppress !== newState.suppress) {
|
||||
// if (newState.suppress) newState.guild.me.voice.setRequestToSpeak(true).catch(Util.noop);
|
||||
// queue.setPaused(newState.suppress);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (oldState.member.id === this.client.user.id && !newState.channelID) {
|
||||
queue.destroy();
|
||||
|
|
|
@ -288,6 +288,14 @@ class Queue<T = unknown> {
|
|||
this.setVolume(amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes the playback
|
||||
* @returns {void}
|
||||
*/
|
||||
mute() {
|
||||
this.volume = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The stream time of this queue
|
||||
* @type {number}
|
||||
|
|
|
@ -96,13 +96,13 @@ class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
|||
});
|
||||
|
||||
this.audioPlayer.on("stateChange", (oldState, newState) => {
|
||||
if (newState.status === AudioPlayerStatus.Idle && oldState.status !== AudioPlayerStatus.Idle) {
|
||||
if (newState.status === AudioPlayerStatus.Playing) {
|
||||
if (!this.paused) return void this.emit("start", this.audioResource);
|
||||
} else if (newState.status === AudioPlayerStatus.Idle && oldState.status !== AudioPlayerStatus.Idle) {
|
||||
if (!this.paused) {
|
||||
void this.emit("finish", this.audioResource);
|
||||
this.audioResource = null;
|
||||
}
|
||||
} else if (newState.status === AudioPlayerStatus.Playing) {
|
||||
if (!this.paused) void this.emit("start", this.audioResource);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue