Skip to content

Commit

Permalink
Fix deleted role mentions in Message.cleanContent (#244)
Browse files Browse the repository at this point in the history
- If role no longer exists, name is replaced with a placeholder.
  • Loading branch information
Brayzure authored and abalabahaha committed Jun 8, 2017
1 parent b8c4b41 commit a084276
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/structures/Message.js
Expand Up @@ -143,7 +143,9 @@ class Message extends Base {

if(this.channel.guild && this.roleMentions) {
for(var roleID of this.roleMentions) {
this._cleanContent = this._cleanContent.replace(new RegExp(`<@&${roleID}>`, "g"), "@" + this.channel.guild.roles.get(roleID).name);
var role = this.channel.guild.roles.get(roleID);
var roleName = role ? role.name : "deleted-role";
this._cleanContent = this._cleanContent.replace(new RegExp(`<@&${roleID}>`, "g"), "@" + roleName);
}
}

Expand Down

0 comments on commit a084276

Please sign in to comment.