diff --git a/bridge.go b/bridge.go index 1e6bffc..48a84b8 100644 --- a/bridge.go +++ b/bridge.go @@ -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.Self.Channel.Send(fmt.Sprintf("%v has joined Discord channel\n", u.Username), false) + Bridge.Client.Do(func() { + Bridge.Client.Self.Channel.Send(fmt.Sprintf("%v has joined Discord channel\n", u.Username), false) + }) } } } diff --git a/handlers.go b/handlers.go index cc7a652..256108f 100644 --- a/handlers.go +++ b/handlers.go @@ -154,7 +154,9 @@ func voiceUpdate(s *discordgo.Session, event *discordgo.VoiceStateUpdate) { } log.Println("user joined watched discord channel") if Bridge.Connected { - Bridge.Client.Self.Channel.Send(fmt.Sprintf("%v has joined Discord channel\n", u.Username), false) + 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.Self.Channel.Send(fmt.Sprintf("%v has left Discord channel\n", u.Username), false) + Bridge.Client.Do(func() { + Bridge.Client.Self.Channel.Send(fmt.Sprintf("%v has left Discord channel\n", u.Username), false) + }) } Bridge.DiscordUserCount = count }