mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-25 04:02:03 -08:00
Fix possible crash on nil (discord)
This commit is contained in:
parent
c5dfe40326
commit
dd3c572256
@ -158,6 +158,7 @@ func (b *bdiscord) getNick(user *discordgo.User) string {
|
|||||||
b.Lock()
|
b.Lock()
|
||||||
defer b.Unlock()
|
defer b.Unlock()
|
||||||
if _, ok := b.userMemberMap[user.ID]; ok {
|
if _, ok := b.userMemberMap[user.ID]; ok {
|
||||||
|
if b.userMemberMap[user.ID] != nil {
|
||||||
if b.userMemberMap[user.ID].Nick != "" {
|
if b.userMemberMap[user.ID].Nick != "" {
|
||||||
// only return if nick is set
|
// only return if nick is set
|
||||||
return b.userMemberMap[user.ID].Nick
|
return b.userMemberMap[user.ID].Nick
|
||||||
@ -165,6 +166,7 @@ func (b *bdiscord) getNick(user *discordgo.User) string {
|
|||||||
// otherwise return username
|
// otherwise return username
|
||||||
return user.Username
|
return user.Username
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// if we didn't find nick, search for it
|
// if we didn't find nick, search for it
|
||||||
b.userMemberMap[user.ID], err = b.c.GuildMember(b.guildID, user.ID)
|
b.userMemberMap[user.ID], err = b.c.GuildMember(b.guildID, user.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user