Skip to content

Commit

Permalink
feat(InteractionResponse): createdTimestamp (#8917)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Dec 14, 2022
1 parent a7b55c1 commit 627511d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/discord.js/src/structures/InteractionResponse.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

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

Expand All @@ -21,6 +22,24 @@ class InteractionResponse {
this.client = interaction.client;
}

/**
* The timestamp the interaction response was created at
* @type {number}
* @readonly
*/
get createdTimestamp() {
return DiscordSnowflake.timestampFrom(this.id);
}

/**
* The time the interaction response was created at
* @type {Date}
* @readonly
*/
get createdAt() {
return new Date(this.createdTimestamp);
}

/**
* Collects a single component interaction that passes the filter.
* The Promise will reject if the time expires.
Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ export class InteractionResponse<Cached extends boolean = boolean> {
public interaction: Interaction<WrapBooleanCache<Cached>>;
public client: Client;
public id: Snowflake;
public get createdAt(): Date;
public get createdTimestamp(): number;
public awaitMessageComponent<T extends MessageComponentType>(
options?: AwaitMessageCollectorOptionsParams<T, Cached>,
): Promise<MappedInteractionTypes<Cached>[T]>;
Expand Down

0 comments on commit 627511d

Please sign in to comment.