Allow MessageMentions#channels to function in DMs

This commit is contained in:
Schuyler Cebulskie
2017-04-29 20:18:23 -04:00
parent aa35e21b84
commit e2c8ba5be0

View File

@@ -55,6 +55,13 @@ class MessageMentions {
*/ */
this._content = message.content; this._content = message.content;
/**
* Client the message is from
* @type {Client}
* @private
*/
this._client = message.client;
/** /**
* Guild the message is in * Guild the message is in
* @type {?Guild} * @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>} * @type {?Collection<Snowflake, GuildChannel>}
* @readonly * @readonly
*/ */
get channels() { get channels() {
if (this._channels) return this._channels; if (this._channels) return this._channels;
if (!this._guild) return null;
this._channels = new Collection(); this._channels = new Collection();
let matches; let matches;
while ((matches = this.constructor.CHANNELS_PATTERN.exec(this._content)) !== null) { 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); if (chan) this._channels.set(chan.id, chan);
} }
return this._channels; return this._channels;