5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-25 07:15:43 +00:00

Fix possible crash on nil (discord)

This commit is contained in:
Wim 2017-05-22 21:57:19 +02:00
parent c5dfe40326
commit dd3c572256

View File

@ -158,12 +158,14 @@ func (b *bdiscord) getNick(user *discordgo.User) string {
b.Lock()
defer b.Unlock()
if _, ok := b.userMemberMap[user.ID]; ok {
if b.userMemberMap[user.ID].Nick != "" {
// only return if nick is set
return b.userMemberMap[user.ID].Nick
if b.userMemberMap[user.ID] != nil {
if b.userMemberMap[user.ID].Nick != "" {
// only return if nick is set
return b.userMemberMap[user.ID].Nick
}
// otherwise return username
return user.Username
}
// otherwise return username
return user.Username
}
// if we didn't find nick, search for it
b.userMemberMap[user.ID], err = b.c.GuildMember(b.guildID, user.ID)