fix(Message): update getters to take null permissions into account (#5066)

* fix(Message): update message#delete

* refactor(Message): message#deletable avoid duplicate call

* Update Message.js

* fix(message): resolve syntax errors

* chore(message): resolve linting issues (death to the gh web panel)

* Update Message.js

* death to the github web panel

* Update src/structures/Message.js

Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com>

Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com>
This commit is contained in:
Zaid
2021-01-22 12:02:21 -05:00
committed by GitHub
parent eb28ee7905
commit 98b1c58218

View File

@@ -386,10 +386,10 @@ class Message extends Base {
* @readonly
*/
get deletable() {
return (
return Boolean(
!this.deleted &&
(this.author.id === this.client.user.id ||
(this.guild && this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_MESSAGES, false)))
(this.author.id === this.client.user.id ||
this.channel.permissionsFor?.(this.client.user)?.has(Permissions.FLAGS.MANAGE_MESSAGES)),
);
}