Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
bot: fix voice state struct
Browse files Browse the repository at this point in the history
  • Loading branch information
sarisia committed May 18, 2020
1 parent 8e7705d commit f9b5938
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions aria/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (b *bot) onMessage(s *discordgo.Session, m *discordgo.MessageCreate) {

func (b *bot) recoverVoiceConnections() {
v := b.voice.cloneJoined()
for c, g := range v {
for g, c := range v {
if err := b.joinVoice(g, c); err != nil {
log.Printf("failedc to recover voice: %v\n", err)
}
Expand Down Expand Up @@ -311,7 +311,7 @@ func (b *bot) disconnectVoice(guildID string) error {
return err
}

b.voice.recordDisconnect(v.ChannelID)
b.voice.recordDisconnect(guildID)
return nil
}

Expand Down
10 changes: 5 additions & 5 deletions aria/voice.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

type voice struct {
sync.RWMutex
joined map[string]string // channelID -> guildID
joined map[string]string // guildID: channelID
}

type voiceState interface {
// cloneJoined returns map contains channelID -> guildID
// cloneJoined returns map contains guildID: channelID
cloneJoined() map[string]string
recordJoin(guildID, channelID string)
recordDisconnect(channelID string)
Expand Down Expand Up @@ -38,12 +38,12 @@ func (v *voice) recordJoin(guildID, channelID string) {
v.Lock()
defer v.Unlock()

v.joined[channelID] = guildID
v.joined[guildID] = channelID
}

func (v *voice) recordDisconnect(channelID string) {
func (v *voice) recordDisconnect(guildID string) {
v.Lock()
defer v.Unlock()

delete(v.joined, channelID)
delete(v.joined, guildID)
}

0 comments on commit f9b5938

Please sign in to comment.