mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
fix(MessageMentions): check guild exists before adding roles (#6313)
This commit is contained in:
@@ -304,7 +304,7 @@ class Message extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.referenced_message) {
|
if (data.referenced_message) {
|
||||||
this.channel?.messages._add(data.referenced_message);
|
this.channel?.messages._add({ guild_id: data.message_reference?.guild_id, ...data.referenced_message });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,17 +59,17 @@ class MessageMentions {
|
|||||||
this.users = new Collection();
|
this.users = new Collection();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roles) {
|
if (roles instanceof Collection) {
|
||||||
if (roles instanceof Collection) {
|
/**
|
||||||
/**
|
* Any roles that were mentioned
|
||||||
* Any roles that were mentioned
|
* <info>Order as received from the API, not as they appear in the message content</info>
|
||||||
* <info>Order as received from the API, not as they appear in the message content</info>
|
* @type {Collection<Snowflake, Role>}
|
||||||
* @type {Collection<Snowflake, Role>}
|
*/
|
||||||
*/
|
this.roles = new Collection(roles);
|
||||||
this.roles = new Collection(roles);
|
} else if (roles) {
|
||||||
} else {
|
this.roles = new Collection();
|
||||||
this.roles = new Collection();
|
const guild = message.guild;
|
||||||
const guild = message.guild;
|
if (guild) {
|
||||||
for (const mention of roles) {
|
for (const mention of roles) {
|
||||||
const role = guild.roles.cache.get(mention);
|
const role = guild.roles.cache.get(mention);
|
||||||
if (role) this.roles.set(role.id, role);
|
if (role) this.roles.set(role.id, role);
|
||||||
|
|||||||
Reference in New Issue
Block a user