31 lines
886 B
JavaScript
Raw Normal View History

'use strict';
const { Events } = require('../../../util/Constants');
module.exports = (client, { d: data }) => {
2022-06-15 23:07:24 +07:00
/**
* Emitted whenever client user send interaction and success
* @event Client#interactionSuccess
* @param {InteractionResponseBody} data data
*/
client.emit(Events.INTERACTION_SUCCESS, data);
2022-10-09 19:37:04 +07:00
// Get channel data
const cache = client._interactionCache.get(data.nonce);
if (!cache) return;
2022-10-09 19:37:04 +07:00
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,
2022-10-09 19:37:04 +07:00
metadata: data_,
error: '',
});
2022-10-09 19:37:04 +07:00
// Delete cache
// client._interactionCache.delete(data.nonce);
};