Skip to content

Commit 3dc2019

Browse files
kyranetfavna
andauthoredNov 16, 2023
refactor(cooldown): improve error message (#689)
* refactor(cooldown): improve error message * fix: grammar Co-authored-by: Jeroen Claassens <support@favware.tech> --------- Co-authored-by: Jeroen Claassens <support@favware.tech>
1 parent a5ce6a5 commit 3dc2019

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed
 

‎src/preconditions/Cooldown.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { container } from '@sapphire/pieces';
22
import { RateLimitManager } from '@sapphire/ratelimits';
3-
import type { ChatInputCommandInteraction, CommandInteraction, ContextMenuCommandInteraction, Message, Snowflake } from 'discord.js';
3+
import {
4+
TimestampStyles,
5+
time,
6+
type ChatInputCommandInteraction,
7+
type CommandInteraction,
8+
type ContextMenuCommandInteraction,
9+
type Message,
10+
type Snowflake
11+
} from 'discord.js';
412
import { Identifiers } from '../lib/errors/Identifiers';
513
import type { Command } from '../lib/structures/Command';
614
import { AllFlowsPrecondition } from '../lib/structures/Precondition';
@@ -62,12 +70,11 @@ export class CorePrecondition extends AllFlowsPrecondition {
6270

6371
if (rateLimit.limited) {
6472
const remaining = rateLimit.remainingTime;
73+
const nextAvailable = time(Math.floor(rateLimit.expires / 1000), TimestampStyles.RelativeTime);
6574

6675
return this.error({
6776
identifier: Identifiers.PreconditionCooldown,
68-
message: `There is a cooldown in effect for this ${commandType} command. It'll be available at ${new Date(
69-
rateLimit.expires
70-
).toISOString()}.`,
77+
message: `There is a cooldown in effect for this ${commandType} command. It'll be available ${nextAvailable}.`,
7178
context: { remaining }
7279
});
7380
}

0 commit comments

Comments
 (0)
Please sign in to comment.