mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
feat(Message): add support for flag editing / embed suppression (#3674)
This commit is contained in:
@@ -6,6 +6,7 @@ const MessageAttachment = require('./MessageAttachment');
|
||||
const { browser } = require('../util/Constants');
|
||||
const Util = require('../util/Util');
|
||||
const { RangeError } = require('../errors');
|
||||
const MessageFlags = require('../util/MessageFlags');
|
||||
|
||||
/**
|
||||
* Represents a message to be sent to the API.
|
||||
@@ -63,6 +64,16 @@ class APIMessage {
|
||||
return this.target instanceof User || this.target instanceof GuildMember;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the target is a message
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get isMessage() {
|
||||
const Message = require('./Message');
|
||||
return this.target instanceof Message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the content of this message.
|
||||
* @returns {?(string|string[])}
|
||||
@@ -126,6 +137,7 @@ class APIMessage {
|
||||
|
||||
const content = this.makeContent();
|
||||
const tts = Boolean(this.options.tts);
|
||||
|
||||
let nonce;
|
||||
if (typeof this.options.nonce !== 'undefined') {
|
||||
nonce = parseInt(this.options.nonce);
|
||||
@@ -149,6 +161,12 @@ class APIMessage {
|
||||
if (this.options.avatarURL) avatarURL = this.options.avatarURL;
|
||||
}
|
||||
|
||||
let flags;
|
||||
if (this.isMessage) {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
flags = this.options.flags != null ? new MessageFlags(this.options.flags).bitfield : this.target.flags.bitfield;
|
||||
}
|
||||
|
||||
this.data = {
|
||||
content,
|
||||
tts,
|
||||
@@ -157,6 +175,7 @@ class APIMessage {
|
||||
embeds,
|
||||
username,
|
||||
avatar_url: avatarURL,
|
||||
flags,
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user