mirror of
https://github.com/projectdysnomia/dysnomia.git
synced 2026-12-02 13:48:31 +02:00
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.
42 lines
1.2 KiB
JavaScript
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;
|