Skip to content

Commit 1d70785

Browse files
committed
Rename destroyPlayer to destroy
1 parent 670a923 commit 1d70785

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

src/main/kotlin/dev/arbjerg/lavalink/client/LavalinkNode.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,18 @@ class LavalinkNode(
158158
*/
159159
fun createOrUpdatePlayer(guildId: Long) = PlayerUpdateBuilder(this, guildId)
160160

161+
@Deprecated(
162+
message = "Doesn't just destroy the player anymore, use destroyPlayerAndLink() instead.",
163+
replaceWith = ReplaceWith("destroyPlayerAndLink(guildId)")
164+
)
165+
fun destroyPlayer(guildId: Long) = destroyPlayerAndLink(guildId)
166+
161167
/**
162-
* Destroy a guild's player. This will also remove the associated link from the client.
168+
* Destroy a guild's player and remove it from the cache. This will also remove the associated link from the client.
163169
*
164-
* @param guildId The guild id of the player to destroy.
170+
* @param guildId The guild id of the player AND link to destroy.
165171
*/
166-
fun destroyPlayer(guildId: Long): Mono<Unit> {
172+
fun destroyPlayerAndLink(guildId: Long): Mono<Unit> {
167173
if (!available) return Mono.error(IllegalStateException("Node is not available"))
168174

169175
return rest.destroyPlayer(guildId)

src/main/kotlin/dev/arbjerg/lavalink/client/Link.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ class Link(
3535
/**
3636
* Destroys the player for this link. This will also remove the link from the client.
3737
*/
38-
fun destroyPlayer() = node.destroyPlayer(guildId)
38+
@Deprecated(
39+
message = "Doesn't just destroy the player anymore, use destroy() instead.",
40+
replaceWith = ReplaceWith("destroy()")
41+
)
42+
fun destroyPlayer() = node.destroyPlayerAndLink(guildId)
43+
44+
/**
45+
* Destroys this link, disconnecting the bot in the process.
46+
*/
47+
fun destroy() = node.destroyPlayerAndLink(guildId)
3948

4049
fun updatePlayer(updateConsumer: Consumer<PlayerUpdateBuilder>) = node.updatePlayer(guildId, updateConsumer)
4150

src/main/kotlin/dev/arbjerg/lavalink/internal/LavalinkSocket.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class LavalinkSocket(private val node: LavalinkNode) : WebSocketListener(), Clos
9797
if (event.code == 4004 || event.code == 4006 || event.code == 4009 || event.code == 4014) {
9898
logger.debug("Node '{}' received close code {} for guild {}", node.name, event.code, event.guildId)
9999
// TODO: auto-reconnect?
100-
node.destroyPlayer(event.guildId.toLong()).subscribe()
100+
node.destroyPlayerAndLink(event.guildId.toLong()).subscribe()
101101
}
102102
}
103103
else -> {}

src/main/kotlin/dev/arbjerg/lavalink/libraries/discord4j/D4JVoiceUpdateHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fun GatewayDiscordClient.installVoiceHandler(lavalink: LavalinkClient): Disposab
3434

3535
if (channel == null && playerState.connected) {
3636
link.state = LinkState.DISCONNECTED
37-
link.destroyPlayer()
37+
link.destroy()
3838
} else {
3939
link.state = LinkState.CONNECTED
4040
Mono.empty()

src/main/kotlin/dev/arbjerg/lavalink/libraries/jda/JDAVoiceUpdateListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class JDAVoiceUpdateListener(private val lavalink: LavalinkClient) : VoiceDispat
3030
link.state = LinkState.CONNECTED
3131
} else {
3232
link.state = LinkState.DISCONNECTED
33-
link.destroyPlayer().subscribe()
33+
link.destroy().subscribe()
3434
}
3535
}
3636

0 commit comments

Comments
 (0)