Skip to content

Commit

Permalink
Get guilds from state for voice connections
Browse files Browse the repository at this point in the history
  • Loading branch information
fakelag committed Feb 18, 2024
1 parent 6a47fce commit 07dda98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions discordplayer/interfaces/discordsessioninterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ func (dds *DefaultDiscordSession) ChannelVoiceJoin(gID string, cID string, mute
}

func (dds *DefaultDiscordSession) Guild(gID string) (guild DiscordGuild, err error) {
g, err := dds.session.Guild(gID)

if err != nil {
return nil, err
for _, guild := range dds.session.State.Guilds {
if guild.ID == gID {
return NewDiscordGuild(guild), nil
}
}

return NewDiscordGuild(g), err
return nil, nil
}

func (dds *DefaultDiscordSession) User(uID string) (user DiscordUser, err error) {
Expand Down
4 changes: 4 additions & 0 deletions discordplayer/voiceworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ func (dms *DiscordMusicSession) hasNonBotMembersInVoiceChannel(voiceChannelID st
return false, err
}

if guild == nil {
return false, errors.New("guild not found")
}

voiceStates := guild.GetVoiceStates()

hasNonBotMembersInVC := false
Expand Down

0 comments on commit 07dda98

Please sign in to comment.