1
0
mirror of https://github.com/stryan/mumble-discord-bridge.git synced 2024-11-22 21:35:44 -05:00

use gumble.Client.Do for sending messages thread safely

This commit is contained in:
stryan 2021-01-05 19:08:17 -05:00
parent 1e8a0a4165
commit 4ae6176991
2 changed files with 9 additions and 3 deletions

View File

@ -114,7 +114,9 @@ func startBridge(discord *discordgo.Session, discordGID string, discordCID strin
if err != nil {
log.Println("error looking up username")
Bridge.DiscordUsers[u.Username] = true
Bridge.Client.Do(func() {
Bridge.Client.Self.Channel.Send(fmt.Sprintf("%v has joined Discord channel\n", u.Username), false)
})
}
}
}

View File

@ -154,7 +154,9 @@ func voiceUpdate(s *discordgo.Session, event *discordgo.VoiceStateUpdate) {
}
log.Println("user joined watched discord channel")
if Bridge.Connected {
Bridge.Client.Do(func() {
Bridge.Client.Self.Channel.Send(fmt.Sprintf("%v has joined Discord channel\n", u.Username), false)
})
}
Bridge.DiscordUsers[u.Username] = true
log.Println(Bridge.DiscordUsers)
@ -184,7 +186,9 @@ func voiceUpdate(s *discordgo.Session, event *discordgo.VoiceStateUpdate) {
delete(Bridge.DiscordUsers, u.Username)
log.Println("user left watched discord channel")
if Bridge.Connected {
Bridge.Client.Do(func() {
Bridge.Client.Self.Channel.Send(fmt.Sprintf("%v has left Discord channel\n", u.Username), false)
})
}
Bridge.DiscordUserCount = count
}