diff --git a/src/structures/Message.js b/src/structures/Message.js index c13dd3ea7..07833f632 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -83,10 +83,12 @@ class Message { * @type {Object} * @property {Map} mentions.users Mentioned users, maps their ID to the user object. * @property {Map} mentions.roles Mentioned roles, maps their ID to the role object. + * @property {Map} mentions.channels Mentioned channels, maps their ID to the channel object. */ this.mentions = { users: new Map(), roles: new Map(), + channels: new Map(), }; /** * 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) { @@ -164,6 +174,13 @@ class Message { if (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); + } + } } /**