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;
/**
* 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;