mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
Add message.mentions.channels
This commit is contained in:
@@ -83,10 +83,12 @@ class Message {
|
|||||||
* @type {Object}
|
* @type {Object}
|
||||||
* @property {Map<String, User>} mentions.users Mentioned users, maps their ID to the user object.
|
* @property {Map<String, User>} mentions.users Mentioned users, maps their ID to the user object.
|
||||||
* @property {Map<String, Role>} mentions.roles Mentioned roles, maps their ID to the role object.
|
* @property {Map<String, Role>} mentions.roles Mentioned roles, maps their ID to the role object.
|
||||||
|
* @property {Map<String, GuildChannel>} mentions.channels Mentioned channels, maps their ID to the channel object.
|
||||||
*/
|
*/
|
||||||
this.mentions = {
|
this.mentions = {
|
||||||
users: new Map(),
|
users: new Map(),
|
||||||
roles: new Map(),
|
roles: new Map(),
|
||||||
|
channels: new Map(),
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* The ID of the message (unique in the channel it was sent)
|
* The ID of the message (unique in the channel it was sent)
|
||||||
@@ -112,6 +114,14 @@ class Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.channel.guild) {
|
||||||
|
const channMentionsRaw = data.content.match(/<#([0-9]{14,20})>/g) || [];
|
||||||
|
for (const raw of channMentionsRaw) {
|
||||||
|
const chan = this.channel.guild.channels.get(raw.match(/([0-9]{14,20})/g)[0]);
|
||||||
|
this.mentions.channels.set(chan.id, chan);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
patch(data) {
|
patch(data) {
|
||||||
@@ -164,6 +174,13 @@ class Message {
|
|||||||
if (data.id) {
|
if (data.id) {
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
}
|
}
|
||||||
|
if (this.channel.guild) {
|
||||||
|
const channMentionsRaw = data.content.match(/<#([0-9]{14,20})>/g) || [];
|
||||||
|
for (const raw of channMentionsRaw) {
|
||||||
|
const chan = this.channel.guild.channels.get(raw.match(/([0-9]{14,20})/g)[0]);
|
||||||
|
this.mentions.channels.set(chan.id, chan);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user