Skip to content

Commit

Permalink
fetchChannel should check the cache by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Didas-git committed Apr 5, 2024
1 parent a2c1bd6 commit 1ac5872
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/transformers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lilybird/transformers",
"version": "0.2.0-alpha.1",
"version": "0.2.0-alpha.2",
"description": "Event transformers and more for lilybird",
"main": "./dist/index.js",
"author": "DidaS",
Expand Down Expand Up @@ -48,7 +48,7 @@
"transformers"
],
"peerDependencies": {
"lilybird": "^0.6.0-alpha.5"
"lilybird": "^0.6.0-beta.1"
},
"devDependencies": {
"eslint": "^8.57.0",
Expand Down
7 changes: 6 additions & 1 deletion packages/transformers/src/factories/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ export class Message {
return channelFactory(this.client, await this.client.rest.startThreadFromMessage(this.channelId, this.id, options));
}

public async fetchChannel(): Promise<Channel> {
public async fetchChannel(force: boolean = false): Promise<Channel> {
if (!force) {
const cachedChannel = await this.client.cache.channels.get(this.channelId);
if (typeof cachedChannel !== "undefined") return cachedChannel;
}

return channelFactory(this.client, await this.client.rest.getChannel(this.channelId));
}

Expand Down

0 comments on commit 1ac5872

Please sign in to comment.