* Processes the song queue for playback. This method checks if the queue is locked or if the player * is busy. If not, it proceeds to play the next song in the queue. This method is also responsible * for handling playback errors and retrying song playback when necessary. It ensures that the q
()
| 176 | * continues to play smoothly, handling transitions between songs, including loop and stop behaviors. |
| 177 | */ |
| 178 | public async processQueue(): Promise<void> { |
| 179 | if (this.queueLock || this.player.state.status !== AudioPlayerStatus.Idle) { |
| 180 | return; |
| 181 | } |
| 182 | |
| 183 | if (!this.songs.length) { |
| 184 | return this.stop(); |
| 185 | } |
| 186 | |
| 187 | this.queueLock = true; |
| 188 | |
| 189 | const next = this.songs[0]; |
| 190 | |
| 191 | try { |
| 192 | const resource = await next.makeResource(); |
| 193 | |
| 194 | this.resource = resource!; |
| 195 | this.player.play(this.resource); |
| 196 | this.resource.volume?.setVolumeLogarithmic(this.volume / 100); |
| 197 | } catch (error) { |
| 198 | console.error(error); |
| 199 | |
| 200 | return this.processQueue(); |
| 201 | } finally { |
| 202 | this.queueLock = false; |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | private async handleSkip(interaction: ButtonInteraction): Promise<void> { |
| 207 | await this.bot.slashCommandsMap.get("skip")!.execute(interaction); |
no test coverage detected