Skip to content

Commit 627511d

Browse files
BenjammingKirbyMrMythicalYTkodiakhq[bot]
authored
feat(InteractionResponse): createdTimestamp (#8917)
* feat(InteractionResponse): createdTimestamp * feat(InteractionResponse): createdTimestamp * Apply suggestions from code review Co-authored-by: MrMythicalYT <[email protected]> Co-authored-by: MrMythicalYT <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent a7b55c1 commit 627511d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/discord.js/src/structures/InteractionResponse.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
const { DiscordSnowflake } = require('@sapphire/snowflake');
34
const { InteractionType } = require('discord-api-types/v10');
45
const { DiscordjsError, ErrorCodes } = require('../errors');
56

@@ -21,6 +22,24 @@ class InteractionResponse {
2122
this.client = interaction.client;
2223
}
2324

25+
/**
26+
* The timestamp the interaction response was created at
27+
* @type {number}
28+
* @readonly
29+
*/
30+
get createdTimestamp() {
31+
return DiscordSnowflake.timestampFrom(this.id);
32+
}
33+
34+
/**
35+
* The time the interaction response was created at
36+
* @type {Date}
37+
* @readonly
38+
*/
39+
get createdAt() {
40+
return new Date(this.createdTimestamp);
41+
}
42+
2443
/**
2544
* Collects a single component interaction that passes the filter.
2645
* The Promise will reject if the time expires.

packages/discord.js/typings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ export class InteractionResponse<Cached extends boolean = boolean> {
555555
public interaction: Interaction<WrapBooleanCache<Cached>>;
556556
public client: Client;
557557
public id: Snowflake;
558+
public get createdAt(): Date;
559+
public get createdTimestamp(): number;
558560
public awaitMessageComponent<T extends MessageComponentType>(
559561
options?: AwaitMessageCollectorOptionsParams<T, Cached>,
560562
): Promise<MappedInteractionTypes<Cached>[T]>;

0 commit comments

Comments
 (0)