mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
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:
@@ -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.
|
||||
|
||||
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -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]>;
|
||||
|
||||
Reference in New Issue
Block a user