From 93d875c237fbdd27bb3e944355488c438286fc48 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Fri, 15 Jul 2022 21:35:23 +0700 Subject: [PATCH] fix: Fetch message from NSFW Channel fix #203 --- src/managers/MessageManager.js | 6 +++++- typings/index.d.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/managers/MessageManager.js b/src/managers/MessageManager.js index 8b7fa9f..ceafb63 100644 --- a/src/managers/MessageManager.js +++ b/src/managers/MessageManager.js @@ -228,6 +228,7 @@ class MessageManager extends CachedManager { channel_id: this.channel.id, max_id: new BigNumber.BigNumber(messageId).plus(1).toString(), min_id: new BigNumber.BigNumber(messageId).minus(1).toString(), + include_nsfw: true, }, }) ).messages[0]; @@ -252,6 +253,7 @@ class MessageManager extends CachedManager { * @property {Array} [channel] An array of channel IDs to filter by * @property {boolean} [pinned] Whether to filter by pinned messages * @property {Array} [has] Message has: `link`, `embed`, `file`, `video`, `image`, or `sound` + * @property {boolean} [nsfw=false] Whether to filter by NSFW channels */ /** @@ -266,7 +268,7 @@ class MessageManager extends CachedManager { * @returns {MessageSearchResult} */ async search(options = {}) { - let { author, content, mentions, has, maxId, minId, channelId, pinned } = Object.assign( + let { author, content, mentions, has, maxId, minId, channelId, pinned, nsfw } = Object.assign( { author: [], content: '', @@ -276,6 +278,7 @@ class MessageManager extends CachedManager { minId: null, channelId: [], pinned: false, + nsfw: false, }, options, ); @@ -289,6 +292,7 @@ class MessageManager extends CachedManager { if (has.length > 0) stringQuery.push(has.map(v => `has=${v}`).join('&')); if (maxId) stringQuery.push(`max_id=${maxId}`); if (minId) stringQuery.push(`min_id=${minId}`); + if (nsfw) stringQuery.push('include_nsfw=true'); if (this.channel.guildId && channelId.length > 0) { stringQuery.push(channelId.map(id => `channel_id=${id}`).join('&')); } diff --git a/typings/index.d.ts b/typings/index.d.ts index 6a32716..c623cba 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3781,6 +3781,7 @@ export interface MessageSearchOptions { minId: Snowflake; channelId: Snowflake[]; pinned: boolean; + nsfw: boolean; } export interface MessageSearchResult {