From 9b2bf03ff6041148a0c6c6351a2bd74c44b4166a Mon Sep 17 00:00:00 2001
From: izexi <43889168+izexi@users.noreply.github.com>
Date: Tue, 19 Mar 2019 19:35:58 +0000
Subject: [PATCH] feat(MessageStore): add cache parameter to fetchPinned()
(#3154)
* add cache param to MessageStore#fetchPinned()
* typings for cache param
* set cache to true by default
---
src/stores/MessageStore.js | 5 +++--
typings/index.d.ts | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/stores/MessageStore.js b/src/stores/MessageStore.js
index 52bf7fdd6..db72114f6 100644
--- a/src/stores/MessageStore.js
+++ b/src/stores/MessageStore.js
@@ -66,6 +66,7 @@ class MessageStore extends DataStore {
* Fetches the pinned messages of this channel and returns a collection of them.
* The returned Collection does not contain any reaction data of the messages.
* Those need to be fetched separately.
+ * @param {boolean} [cache=true] Whether to cache the message(s)
* @returns {Promise>}
* @example
* // Get pinned messages
@@ -73,10 +74,10 @@ class MessageStore extends DataStore {
* .then(messages => console.log(`Received ${messages.size} messages`))
* .catch(console.error);
*/
- fetchPinned() {
+ fetchPinned(cache = true) {
return this.client.api.channels[this.channel.id].pins.get().then(data => {
const messages = new Collection();
- for (const message of data) messages.set(message.id, this.add(message));
+ for (const message of data) messages.set(message.id, this.add(message, cache));
return messages;
});
}
diff --git a/typings/index.d.ts b/typings/index.d.ts
index 3f9f222af..e1a6bac84 100644
--- a/typings/index.d.ts
+++ b/typings/index.d.ts
@@ -1366,9 +1366,9 @@ declare module 'discord.js' {
export class MessageStore extends DataStore {
constructor(channel: TextChannel | DMChannel, iterable?: Iterable);
- public fetch(message: Snowflake): Promise;
- public fetch(options?: ChannelLogsQueryOptions): Promise>;
- public fetchPinned(): Promise>;
+ public fetch(message: Snowflake, cache?: boolean): Promise;
+ public fetch(options?: ChannelLogsQueryOptions, cache?: boolean): Promise>;
+ public fetchPinned(cache?: boolean): Promise>;
}
export class PresenceStore extends DataStore {