Skip to content

Commit ba0a6e3

Browse files
authored
Merge pull request #125 from smichel17/crashfix
Fix: Don't crash if a message has no author
2 parents 14bf8f8 + d29c358 commit ba0a6e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/modules/helpchan.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ export class HelpChanModule extends Module {
356356
// to creation date), so sorting is needed to find the latest embed.
357357
let lastMessage = channel.messages.cache
358358
.array()
359-
.filter(m => m.author.id === this.client.user?.id)
359+
.filter(m => m.author && m.author.id === this.client.user?.id)
360360
.sort((m1, m2) => m2.createdTimestamp - m1.createdTimestamp)
361361
.find(m => m.embeds.some(isStatusEmbed));
362362

363363
if (!lastMessage)
364364
// Fetch has a stable order, with recent messages first
365365
lastMessage = (await channel.messages.fetch({ limit: 5 }))
366366
.array()
367-
.filter(m => m.author.id === this.client.user?.id)
367+
.filter(m => m.author && m.author.id === this.client.user?.id)
368368
.find(m => m.embeds.some(isStatusEmbed));
369369

370370
if (lastMessage) {

0 commit comments

Comments
 (0)