mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Allow MessageMentions#channels to function in DMs
This commit is contained in:
@@ -55,6 +55,13 @@ class MessageMentions {
|
||||
*/
|
||||
this._content = message.content;
|
||||
|
||||
/**
|
||||
* Client the message is from
|
||||
* @type {Client}
|
||||
* @private
|
||||
*/
|
||||
this._client = message.client;
|
||||
|
||||
/**
|
||||
* Guild the message is in
|
||||
* @type {?Guild}
|
||||
@@ -94,17 +101,16 @@ class MessageMentions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Any channels that were mentioned (only in {@link TextChannel}s)
|
||||
* Any channels that were mentioned
|
||||
* @type {?Collection<Snowflake, GuildChannel>}
|
||||
* @readonly
|
||||
*/
|
||||
get channels() {
|
||||
if (this._channels) return this._channels;
|
||||
if (!this._guild) return null;
|
||||
this._channels = new Collection();
|
||||
let matches;
|
||||
while ((matches = this.constructor.CHANNELS_PATTERN.exec(this._content)) !== null) {
|
||||
const chan = this._guild.channels.get(matches[1]);
|
||||
const chan = this._client.channels.get(matches[1]);
|
||||
if (chan) this._channels.set(chan.id, chan);
|
||||
}
|
||||
return this._channels;
|
||||
|
||||
Reference in New Issue
Block a user