summaryrefslogtreecommitdiffstats
path: root/bridge/discord
diff options
context:
space:
mode:
authorJames Nylen <jnylen@gmail.com>2019-01-07 15:39:53 -0500
committerWim <wim@42.be>2019-01-07 21:39:53 +0100
commit492722af8b1962581802465581e3a041880b8808 (patch)
tree6edb7e868ef7a9e5442d765c944e7582b43f633c /bridge/discord
parent56749dfb205857c6f3877f016ffe2b4ba4014725 (diff)
downloadmatterbridge-msglm-492722af8b1962581802465581e3a041880b8808.tar.gz
matterbridge-msglm-492722af8b1962581802465581e3a041880b8808.tar.bz2
matterbridge-msglm-492722af8b1962581802465581e3a041880b8808.zip
Improve error reporting on failure to join Discord. Fixes #672 (#680)
Diffstat (limited to 'bridge/discord')
-rw-r--r--bridge/discord/discord.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index 16ce8c05..f27210b5 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -2,6 +2,7 @@ package bdiscord
import (
"bytes"
+ "errors"
"fmt"
"strings"
"sync"
@@ -49,6 +50,7 @@ func New(cfg *bridge.Config) bridge.Bridger {
func (b *Bdiscord) Connect() error {
var err error
var token string
+ var guildFound bool
b.Log.Info("Connecting")
if b.GetString("WebhookURL") == "" {
b.Log.Info("Connecting using token")
@@ -86,12 +88,24 @@ func (b *Bdiscord) Connect() error {
if guild.Name == serverName || guild.ID == serverName {
b.channels, err = b.c.GuildChannels(guild.ID)
b.guildID = guild.ID
+ guildFound = true
if err != nil {
break
}
}
}
b.channelsMutex.Unlock()
+ if !guildFound {
+ msg := fmt.Sprintf("Server \"%s\" not found", b.GetString("Server"))
+ err = errors.New(msg)
+ b.Log.Error(msg)
+ b.Log.Info("Possible values:")
+ for _, guild := range guilds {
+ b.Log.Infof("Server=\"%s\" # Server name", guild.Name)
+ b.Log.Infof("Server=\"%s\" # Server ID", guild.ID)
+ }
+ }
+
if err != nil {
return err
}
@@ -106,7 +120,7 @@ func (b *Bdiscord) Connect() error {
defer b.membersMutex.Unlock()
members, err := b.c.GuildMembers(b.guildID, "", 1000)
if err != nil {
- b.Log.Error("Error obtaining guild members", err)
+ b.Log.Error("Error obtaining server members: ", err)
return err
}
for _, member := range members {