Skip to content

Commit 310c42e

Browse files
authored
Merge pull request #173 from Josh-Cena/ask-timeout
fix sending !helper too fast bypassing timeout
2 parents f75faab + 0de66f0 commit 310c42e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/modules/helpchan.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,16 @@ export class HelpChanModule extends Module {
304304

305305
// Ensure they've waited long enough
306306
// Trusted members (who aren't the asker) are allowed to disregard the timeout
307-
const askTime = msg.channel.lastPinTimestamp ?? 0;
307+
const askTime = msg.channel.lastPinTimestamp;
308+
if (!askTime) {
309+
// This happens when the command is sent before the message is pinned
310+
return msg.channel.send(
311+
`:warning: Please wait a bit longer. You can ping helpers <t:${
312+
// Not accurate, but good enough
313+
(Date.now() + timeBeforeHelperPing) / 1000
314+
}:R>.`,
315+
);
316+
}
308317
const pingAllowedAfter = askTime + timeBeforeHelperPing;
309318

310319
if (isAsker && Date.now() < pingAllowedAfter) {

0 commit comments

Comments
 (0)