mirror of
https://github.com/ION606/custom_discordjs.git
synced 2026-05-14 22:26:54 +00:00
Fixed interactions and added the deferReply feature
This commit is contained in:
@@ -68,15 +68,16 @@ export class Modal extends Interaction {
|
||||
* @returns {Boolean} true is added false otherwise
|
||||
*/
|
||||
addComponent(c) {
|
||||
if (!c || this.components.has(c.custom_id)) return true;
|
||||
if (!c || this.components.has(c.custom_id)) return false;
|
||||
this.components.set(c.custom_id, c);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description returns the Modal's components as a map of
|
||||
*
|
||||
* `custom_id ==> input`
|
||||
* @returns {[{value: String, custom_id: String}]}
|
||||
* @returns {Map<String, ModalComponent>}
|
||||
*/
|
||||
getComponents() {
|
||||
const m = new Map();
|
||||
@@ -96,9 +97,10 @@ export class Modal extends Interaction {
|
||||
}
|
||||
|
||||
toObj() {
|
||||
if (this.components.size == 0) throw "MODAL MUST HAVE AT LEAST 1 COMPONENT!";
|
||||
const obj = {title: this.title, custom_id: this.custom_id, components: []};
|
||||
for (const key in this.components) {
|
||||
const comp = this.components.get(key);
|
||||
|
||||
for (const [key, comp] of this.components) {
|
||||
const a = new MessageActionRow();
|
||||
a.addComponent(comp);
|
||||
obj.components.push(a.toObj());
|
||||
|
||||
@@ -60,6 +60,16 @@ export class Interaction extends DataManager {
|
||||
/** @type {interactionOptions} */
|
||||
data;
|
||||
|
||||
async deferReply() {
|
||||
try {
|
||||
await this.client.axiosCustom.post(`/interactions/${this.id}/${this.#token}/callback`, {
|
||||
type: 5
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Modal} m
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user