From 5ac22691d26cd5f396f574efb112f75d0eeeeed6 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Wed, 26 Apr 2017 17:01:27 -0500 Subject: [PATCH] Add TextBasedChannel#nsfw (excluding User and GuildMember) (#1419) --- src/structures/GroupDMChannel.js | 1 + src/structures/TextChannel.js | 1 + src/structures/interfaces/TextBasedChannel.js | 12 +++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/structures/GroupDMChannel.js b/src/structures/GroupDMChannel.js index 15eea2c22..c51ede298 100644 --- a/src/structures/GroupDMChannel.js +++ b/src/structures/GroupDMChannel.js @@ -172,6 +172,7 @@ class GroupDMChannel extends Channel { awaitMessages() {} // Doesn't work on group DMs; bulkDelete() {} acknowledge() {} + get nsfw() {} _cacheMessage() {} } diff --git a/src/structures/TextChannel.js b/src/structures/TextChannel.js index 617c17a78..429cf61e5 100644 --- a/src/structures/TextChannel.js +++ b/src/structures/TextChannel.js @@ -88,6 +88,7 @@ class TextChannel extends GuildChannel { stopTyping() {} get typing() {} get typingCount() {} + get nsfw() {} createCollector() {} createMessageCollector() {} awaitMessages() {} diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index 8eec647db..e87edff92 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -389,6 +389,15 @@ class TextBasedChannel { return this.client.rest.methods.ackTextChannel(this); } + /** + * If the Discord Client considers this channel NSFW + * @type {boolean} + * @readonly + */ + get nsfw() { + return /^nsfw(-|$)/.test(this.name); + } + _cacheMessage(message) { const maxSize = this.client.options.messageCacheMaxSize; if (maxSize === 0) return null; @@ -493,7 +502,8 @@ exports.applyToClass = (structure, full = false, ignore = []) => { 'fetchPinnedMessages', 'createCollector', 'createMessageCollector', - 'awaitMessages' + 'awaitMessages', + 'nsfw' ); } for (const prop of props) {