mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
Add Message.editable/deletable/pinnable
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,6 +1,7 @@
|
|||||||
const Attachment = require('./MessageAttachment');
|
const Attachment = require('./MessageAttachment');
|
||||||
const Embed = require('./MessageEmbed');
|
const Embed = require('./MessageEmbed');
|
||||||
const Collection = require('../util/Collection');
|
const Collection = require('../util/Collection');
|
||||||
|
const Constants = require('../util/Constants');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Message on Discord
|
* Represents a Message on Discord
|
||||||
@@ -246,6 +247,33 @@ class Message {
|
|||||||
return this._edits.slice().unshift(this);
|
return this._edits.slice().unshift(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the message is editable by the client user.
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
get editable() {
|
||||||
|
return this.author.id === this.client.user.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the message is deletable by the client user.
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
get deletable() {
|
||||||
|
return this.author.id === this.client.user.id || (this.guild &&
|
||||||
|
this.channel.permissionsFor(this.client.user).hasPermission(Constants.PermissionFlags.MANAGE_MESSAGES)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the message is pinnable by the client user.
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
get pinnable() {
|
||||||
|
return !this.guild ||
|
||||||
|
this.channel.permissionsFor(this.client.user).hasPermission(Constants.PermissionFlags.MANAGE_MESSAGES);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not a user, channel or role is mentioned in this message.
|
* Whether or not a user, channel or role is mentioned in this message.
|
||||||
* @param {GuildChannel|User|Role|string} data either a guild channel, user or a role object, or a string representing
|
* @param {GuildChannel|User|Role|string} data either a guild channel, user or a role object, or a string representing
|
||||||
|
|||||||
Reference in New Issue
Block a user