feat: awaitModal

This commit is contained in:
March 7th
2022-10-09 19:37:04 +07:00
parent fecfa7d03b
commit a141adf385
17 changed files with 335 additions and 67 deletions

View File

@@ -204,6 +204,8 @@ class Client extends BaseClient {
this.token = null;
}
this._interactionCache = new Collection();
/**
* User that the client is logged in as
* @type {?ClientUser}
@@ -340,7 +342,7 @@ class Client extends BaseClient {
this.emit(Events.DEBUG, `Added Fingerprint: ${res.data.fingerprint}`);
})
.catch(err => {
this.emit(Events.DEBUG, `Finding Cookie and Fingerprint failed: ${err.message}`);
this.emit(Events.DEBUG, `Update Cookie and Fingerprint failed: ${err.message}`);
});
}

View File

@@ -12,4 +12,6 @@ module.exports = (client, { d: data }) => {
status: false,
metadata: data,
});
// Delete cache
client._interactionCache.delete(data.nonce);
};

View File

@@ -8,8 +8,21 @@ module.exports = (client, { d: data }) => {
* @param {InteractionResponseBody} data data
*/
client.emit(Events.INTERACTION_SUCCESS, data);
// Get channel data
const cache = client._interactionCache.get(data.nonce);
const channel = cache.guildId
? client.guilds.cache.get(cache.guildId)?.channels.cache.get(cache.channelId)
: client.channels.cache.get(cache.channelId);
// Set data
const interaction = {
...cache,
...data,
};
const data_ = channel.interactions._add(interaction);
client.emit('interactionResponse', {
status: true,
metadata: data,
metadata: data_,
});
// Delete cache
// client._interactionCache.delete(data.nonce);
};