Skip to content

Commit 10e2fcf

Browse files
committed
don't call OnDestroyPlayer when player is already destroyed
1 parent f2eeed8 commit 10e2fcf

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

disgolink/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
"runtime/debug"
88
"sync"
99

10-
"github.com/disgoorg/disgolink/v3/lavalink"
1110
"github.com/disgoorg/snowflake/v2"
11+
12+
"github.com/disgoorg/disgolink/v3/lavalink"
1213
)
1314

1415
type Client interface {

disgolink/player.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ func (p *playerImpl) Destroy(ctx context.Context) error {
153153
return err
154154
}
155155

156+
// check if this player already got destroyed
157+
if player := p.lavalink.ExistingPlayer(p.guildID); player == nil {
158+
return nil
159+
}
160+
156161
p.lavalink.ForPlugins(func(plugin Plugin) {
157162
if pl, ok := plugin.(PluginEventHandler); ok {
158163
pl.OnDestroyPlayer(p)

disgolink/rest_client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010
"net/http"
1111
"net/url"
1212

13-
"github.com/disgoorg/disgolink/v3/lavalink"
1413
"github.com/disgoorg/snowflake/v2"
14+
15+
"github.com/disgoorg/disgolink/v3/lavalink"
1516
)
1617

1718
type Endpoint string

0 commit comments

Comments
 (0)