1. Fix message.mentions
This commit is contained in:
parent
4e870872f5
commit
ab113790e3
@ -11,8 +11,8 @@ const {
|
|||||||
} = require('../util/Constants');
|
} = require('../util/Constants');
|
||||||
|
|
||||||
function parseResponse(res) {
|
function parseResponse(res) {
|
||||||
if (res.headers.get('content-type').startsWith('application/json')) return res.json();
|
if (res.headers.get('content-type').startsWith('application/json')) return res.json();
|
||||||
return res.buffer();
|
return res.arrayBuffer(); // Cre: TheDevYellowy
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAPIOffset(serverDate) {
|
function getAPIOffset(serverDate) {
|
||||||
|
@ -225,19 +225,14 @@ class Message extends Base {
|
|||||||
* All valid mentions that the message contains
|
* All valid mentions that the message contains
|
||||||
* @type {MessageMentions}
|
* @type {MessageMentions}
|
||||||
*/
|
*/
|
||||||
if (!data.mentions)
|
this.mentions = new Mentions(
|
||||||
this.mentions = new Mentions(
|
this,
|
||||||
this,
|
data.mentions,
|
||||||
data.mentions,
|
data.mention_roles,
|
||||||
data.mention_roles,
|
data.mention_everyone,
|
||||||
data.mention_everyone,
|
data.mention_channels,
|
||||||
data.mention_channels,
|
data.referenced_message?.author,
|
||||||
data.referenced_message?.author,
|
);
|
||||||
);
|
|
||||||
else
|
|
||||||
data.mentions instanceof Mentions
|
|
||||||
? (this.mentions = data.mentions)
|
|
||||||
: (this.mentions = null);
|
|
||||||
} else {
|
} else {
|
||||||
this.mentions = new Mentions(
|
this.mentions = new Mentions(
|
||||||
this,
|
this,
|
||||||
@ -491,9 +486,8 @@ class Message extends Base {
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get url() {
|
get url() {
|
||||||
return `https://discord.com/channels/${this.guildId ?? '@me'}/${
|
return `https://discord.com/channels/${this.guildId ?? '@me'}/${this.channelId
|
||||||
this.channelId
|
}/${this.id}`;
|
||||||
}/${this.id}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -619,8 +613,8 @@ class Message extends Base {
|
|||||||
get editable() {
|
get editable() {
|
||||||
const precheck = Boolean(
|
const precheck = Boolean(
|
||||||
this.author.id === this.client.user.id &&
|
this.author.id === this.client.user.id &&
|
||||||
!deletedMessages.has(this) &&
|
!deletedMessages.has(this) &&
|
||||||
(!this.guild || this.channel?.viewable),
|
(!this.guild || this.channel?.viewable),
|
||||||
);
|
);
|
||||||
// Regardless of permissions thread messages cannot be edited if
|
// Regardless of permissions thread messages cannot be edited if
|
||||||
// the thread is locked.
|
// the thread is locked.
|
||||||
@ -654,8 +648,8 @@ class Message extends Base {
|
|||||||
|
|
||||||
return Boolean(
|
return Boolean(
|
||||||
this.author.id === this.client.user.id ||
|
this.author.id === this.client.user.id ||
|
||||||
(permissions.has(Permissions.FLAGS.MANAGE_MESSAGES, false) &&
|
(permissions.has(Permissions.FLAGS.MANAGE_MESSAGES, false) &&
|
||||||
this.guild.me.communicationDisabledUntilTimestamp < Date.now()),
|
this.guild.me.communicationDisabledUntilTimestamp < Date.now()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,12 +662,12 @@ class Message extends Base {
|
|||||||
const { channel } = this;
|
const { channel } = this;
|
||||||
return Boolean(
|
return Boolean(
|
||||||
!this.system &&
|
!this.system &&
|
||||||
!deletedMessages.has(this) &&
|
!deletedMessages.has(this) &&
|
||||||
(!this.guild ||
|
(!this.guild ||
|
||||||
(channel?.viewable &&
|
(channel?.viewable &&
|
||||||
channel
|
channel
|
||||||
?.permissionsFor(this.client.user)
|
?.permissionsFor(this.client.user)
|
||||||
?.has(Permissions.FLAGS.MANAGE_MESSAGES, false))),
|
?.has(Permissions.FLAGS.MANAGE_MESSAGES, false))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,11 +698,11 @@ class Message extends Base {
|
|||||||
const { channel } = this;
|
const { channel } = this;
|
||||||
return Boolean(
|
return Boolean(
|
||||||
channel?.type === 'GUILD_NEWS' &&
|
channel?.type === 'GUILD_NEWS' &&
|
||||||
!this.flags.has(MessageFlags.FLAGS.CROSSPOSTED) &&
|
!this.flags.has(MessageFlags.FLAGS.CROSSPOSTED) &&
|
||||||
this.type === 'DEFAULT' &&
|
this.type === 'DEFAULT' &&
|
||||||
channel.viewable &&
|
channel.viewable &&
|
||||||
channel.permissionsFor(this.client.user)?.has(bitfield, false) &&
|
channel.permissionsFor(this.client.user)?.has(bitfield, false) &&
|
||||||
!deletedMessages.has(this),
|
!deletedMessages.has(this),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,7 +1091,7 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
async contextMenu(botID, commandName) {
|
async contextMenu(botID, commandName) {
|
||||||
if (!botID) throw new Error('Bot ID is required');
|
if (!botID) throw new Error('Bot ID is required');
|
||||||
const user = await this.client.users.fetch(botID).catch(() => {});
|
const user = await this.client.users.fetch(botID).catch(() => { });
|
||||||
if (!user || !user.bot || !user.applications)
|
if (!user || !user.bot || !user.applications)
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'BotID is not a bot or does not have an application slash command',
|
'BotID is not a bot or does not have an application slash command',
|
||||||
|
Loading…
Reference in New Issue
Block a user