Files
TTtie dc3129e2a4 refactor: switch to ESLint flat config, add JSDoc linting (#147)
This commit switches Dysnomia over to ESLint flat config for
futureproofing and better maintainability. For the most part, the
codebase will pass the test suite, apart from a few exceptions
introduced by the stylistic plugin which I believe are reasonable to
include.

Additionally, JSDoc linting was added to maintain proper 
alignment of various features.
2024-08-02 18:56:44 +00:00

42 lines
1.2 KiB
JavaScript

"use strict";
const Interaction = require("./Interaction");
const {InteractionResponseTypes} = require("../Constants");
/**
* Represents a ping interaction. See Interaction for more properties.
* @extends Interaction
*/
class PingInteraction extends Interaction {
#client;
constructor(data, client) {
super(data, client);
this.#client = client;
}
/**
* Acknowledges the ping interaction with a pong response.
* Note: You can **not** use more than 1 initial interaction response per interaction.
* @returns {Promise}
*/
acknowledge() {
return this.pong();
}
/**
* Acknowledges the ping interaction with a pong response.
* Note: You can **not** use more than 1 initial interaction response per interaction.
* @returns {Promise}
*/
pong() {
if(this.acknowledged === true) {
throw new Error("You have already acknowledged this interaction.");
}
return this.#client.createInteractionResponse.call(this.#client, this.id, this.token, {
type: InteractionResponseTypes.PONG
}).then(() => this.update());
}
}
module.exports = PingInteraction;