feat(InteractionResponse): createdTimestamp (#8917)

* feat(InteractionResponse): createdTimestamp

* feat(InteractionResponse): createdTimestamp

* Apply suggestions from code review

Co-authored-by: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com>

Co-authored-by: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Ben
2022-12-14 16:35:40 -05:00
committed by GitHub
parent a7b55c1460
commit 627511d652
2 changed files with 21 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
'use strict';
const { DiscordSnowflake } = require('@sapphire/snowflake');
const { InteractionType } = require('discord-api-types/v10');
const { DiscordjsError, ErrorCodes } = require('../errors');
@@ -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.

View File

@@ -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]>;