use gumble.Client.Do for sending messages thread safely
This commit is contained in:
parent
1e8a0a4165
commit
4ae6176991
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user