diff options
author | Wim <wim@42.be> | 2017-05-22 21:57:19 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-05-22 21:57:19 +0200 |
commit | dd3c572256db1f6bce8cc604babace6865a331c4 (patch) | |
tree | 23beab2a9625ddcadc29766a66f72501b73100a4 /bridge/discord/discord.go | |
parent | c5dfe4032657c46a5fa241745885b295950f83d3 (diff) | |
download | matterbridge-msglm-dd3c572256db1f6bce8cc604babace6865a331c4.tar.gz matterbridge-msglm-dd3c572256db1f6bce8cc604babace6865a331c4.tar.bz2 matterbridge-msglm-dd3c572256db1f6bce8cc604babace6865a331c4.zip |
Fix possible crash on nil (discord)
Diffstat (limited to 'bridge/discord/discord.go')
-rw-r--r-- | bridge/discord/discord.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index 2a91adf9..f6f3077f 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -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) |