mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-18 17:12:37 +01:00
parent
56749dfb20
commit
492722af8b
@ -2,6 +2,7 @@ package bdiscord
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -49,6 +50,7 @@ func New(cfg *bridge.Config) bridge.Bridger {
|
|||||||
func (b *Bdiscord) Connect() error {
|
func (b *Bdiscord) Connect() error {
|
||||||
var err error
|
var err error
|
||||||
var token string
|
var token string
|
||||||
|
var guildFound bool
|
||||||
b.Log.Info("Connecting")
|
b.Log.Info("Connecting")
|
||||||
if b.GetString("WebhookURL") == "" {
|
if b.GetString("WebhookURL") == "" {
|
||||||
b.Log.Info("Connecting using token")
|
b.Log.Info("Connecting using token")
|
||||||
@ -86,12 +88,24 @@ func (b *Bdiscord) Connect() error {
|
|||||||
if guild.Name == serverName || guild.ID == serverName {
|
if guild.Name == serverName || guild.ID == serverName {
|
||||||
b.channels, err = b.c.GuildChannels(guild.ID)
|
b.channels, err = b.c.GuildChannels(guild.ID)
|
||||||
b.guildID = guild.ID
|
b.guildID = guild.ID
|
||||||
|
guildFound = true
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b.channelsMutex.Unlock()
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -106,7 +120,7 @@ func (b *Bdiscord) Connect() error {
|
|||||||
defer b.membersMutex.Unlock()
|
defer b.membersMutex.Unlock()
|
||||||
members, err := b.c.GuildMembers(b.guildID, "", 1000)
|
members, err := b.c.GuildMembers(b.guildID, "", 1000)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Log.Error("Error obtaining guild members", err)
|
b.Log.Error("Error obtaining server members: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
|
Loading…
Reference in New Issue
Block a user