Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(MessageMentions): check guild exists before adding roles #6313

Merged
merged 2 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class Message extends Base {
}

if (data.referenced_message) {
this.channel?.messages._add(data.referenced_message);
vladfrangu marked this conversation as resolved.
Show resolved Hide resolved
this.channel?.messages._add({ guild_id: data.message_reference?.guild_id, ...data.referenced_message });
}

/**
Expand Down
22 changes: 11 additions & 11 deletions src/structures/MessageMentions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ class MessageMentions {
this.users = new Collection();
}

if (roles) {
if (roles instanceof Collection) {
/**
* Any roles that were mentioned
* <info>Order as received from the API, not as they appear in the message content</info>
* @type {Collection<Snowflake, Role>}
*/
this.roles = new Collection(roles);
} else {
this.roles = new Collection();
const guild = message.guild;
if (roles instanceof Collection) {
/**
* Any roles that were mentioned
* <info>Order as received from the API, not as they appear in the message content</info>
* @type {Collection<Snowflake, Role>}
*/
this.roles = new Collection(roles);
} else if (roles) {
this.roles = new Collection();
const guild = message.guild;
if (guild) {
for (const mention of roles) {
const role = guild.roles.cache.get(mention);
if (role) this.roles.set(role.id, role);
Expand Down