Skip to content

Commit

Permalink
Fix webhooks for users with no avatars (#530)
Browse files Browse the repository at this point in the history
* Consistently use this.bot in tests

Some tests were subtly testing broken behavior,
as this.addUser was not correctly adding a user
to the given bot's guild.

* Group up webhook tests in contexts

* Fix webhooks for users with no avatars

Fixes #529.
  • Loading branch information
Throne3d authored Jan 4, 2020
1 parent 88fecf3 commit 4fe1483
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 174 deletions.
3 changes: 2 additions & 1 deletion lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ class Bot {

// No matching user or more than one => default avatar
if (users && users.size === 1) {
return users.first().user.avatarURL.replace(/\?size=\d{1,}$/, '?size=128');
const url = users.first().user.avatarURL;
if (url) return url.replace(/\?size=\d{1,}$/, '?size=128');
}

// If there isn't a URL format, don't send an avatar at all
Expand Down
Loading

0 comments on commit 4fe1483

Please sign in to comment.