Skip to content

Commit 7f8dddf

Browse files
committed
fetch dormant message if not in cache
1 parent 6afc7e0 commit 7f8dddf

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"scripts": {
3434
"start": "ts-node-dev --respawn src",
3535
"build": "tsc",
36-
"lint": "prettier --check 'src/**/*.ts'",
37-
"lint:fix": "prettier 'src/**/*.ts' --write "
36+
"lint": "prettier --check src/**/*.ts",
37+
"lint:fix": "prettier src/**/*.ts --write "
3838
}
3939
}

src/modules/helpchan.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,17 @@ export class HelpChanModule extends Module {
177177
if (dormant && dormant instanceof TextChannel) {
178178
await this.moveChannel(dormant, categories.ask);
179179

180-
const lastMessage = dormant.messages.cache
180+
let lastMessage = dormant.messages.cache
181181
.array()
182182
.reverse()
183183
.find(m => m.author.id === this.client.user?.id);
184+
185+
if (!lastMessage)
186+
lastMessage = (await dormant.messages.fetch({ limit: 5 }))
187+
.array()
188+
.reverse()
189+
.find(m => m.author.id === this.client.user?.id);
190+
184191
if (lastMessage) {
185192
// If there is a last message (the dormant message) by the bot, just edit it
186193
await lastMessage.edit(this.AVAILABLE_EMBED);

0 commit comments

Comments
 (0)