Skip to content

Commit a7d6b7a

Browse files
committed
feat: close the channel if the asker leaves the server
1 parent cf6f370 commit a7d6b7a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/modules/helpchan.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,23 @@ export class HelpChanModule extends Module {
419419

420420
private async checkDormantPossibilities() {
421421
for (const channel of this.getOngoingChannels()) {
422-
const messages = await channel.messages.fetch();
422+
const [messages, member] = await Promise.all([
423+
channel.messages.fetch(),
424+
this.getChannelMember(channel),
425+
]);
423426

424427
const diff =
425428
Date.now() - (messages.first()?.createdAt.getTime() ?? 0);
426429

427-
if (diff > dormantChannelTimeout)
430+
if (!member) {
431+
await channel.send(
432+
'Asker has left the server, closing channel...',
433+
);
434+
}
435+
if (!member || diff > dormantChannelTimeout) {
428436
await this.markChannelAsDormant(channel);
437+
continue;
438+
}
429439
}
430440
}
431441

0 commit comments

Comments
 (0)