mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
Clean up and add comments
This commit is contained in:
@@ -128,24 +128,27 @@ class Message {
|
|||||||
everyone: data.mention_everyone,
|
everyone: data.mention_everyone,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add user mentions
|
||||||
for (const mention of data.mentions) {
|
for (const mention of data.mentions) {
|
||||||
let user = this.client.users.get(mention.id);
|
let user = this.client.users.get(mention.id);
|
||||||
if (!user) user = this.client.dataManager.newUser(mention);
|
if (!user) user = this.client.dataManager.newUser(mention);
|
||||||
this.mentions.users.set(user.id, user);
|
this.mentions.users.set(user.id, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add getter for member mentions
|
||||||
Object.defineProperty(this.mentions, 'members', {
|
Object.defineProperty(this.mentions, 'members', {
|
||||||
get: () => {
|
get: () => {
|
||||||
if (this.channel.type !== 'text') return null;
|
if (this.channel.type !== 'text') return null;
|
||||||
const members = new Collection();
|
const members = new Collection();
|
||||||
this.mentions.users.forEach(user => {
|
this.mentions.users.forEach(user => {
|
||||||
const member = this.client.resolver.resolveGuildMember(this.guild, user);
|
const member = this.client.resolver.resolveGuildMember(this.channel.guild, user);
|
||||||
if (member) members.set(member.id, member);
|
if (member) members.set(member.id, member);
|
||||||
});
|
});
|
||||||
return members;
|
return members;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add role mentions
|
||||||
if (data.mention_roles) {
|
if (data.mention_roles) {
|
||||||
for (const mention of data.mention_roles) {
|
for (const mention of data.mention_roles) {
|
||||||
const role = this.channel.guild.roles.get(mention);
|
const role = this.channel.guild.roles.get(mention);
|
||||||
@@ -153,7 +156,8 @@ class Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.channel.guild) {
|
// Add channel mentions
|
||||||
|
if (this.channel.type === 'text') {
|
||||||
const channMentionsRaw = data.content.match(/<#([0-9]{14,20})>/g) || [];
|
const channMentionsRaw = data.content.match(/<#([0-9]{14,20})>/g) || [];
|
||||||
for (const raw of channMentionsRaw) {
|
for (const raw of channMentionsRaw) {
|
||||||
const chan = this.channel.guild.channels.get(raw.match(/([0-9]{14,20})/g)[0]);
|
const chan = this.channel.guild.channels.get(raw.match(/([0-9]{14,20})/g)[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user