2022-04-12 20:46:25 +07:00
|
|
|
'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
|
|
|
|
*/
|
2022-04-16 17:44:43 +07:00
|
|
|
client.emit(Events.INTERACTION_SUCCESS, data);
|
2022-10-09 19:37:04 +07:00
|
|
|
// Get channel data
|
|
|
|
const cache = client._interactionCache.get(data.nonce);
|
2022-10-11 17:19:57 +07:00
|
|
|
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);
|
2022-07-12 19:30:18 +07:00
|
|
|
client.emit('interactionResponse', {
|
|
|
|
status: true,
|
2022-10-09 19:37:04 +07:00
|
|
|
metadata: data_,
|
2022-10-30 19:25:32 +07:00
|
|
|
error: '',
|
2022-07-12 19:30:18 +07:00
|
|
|
});
|
2022-10-09 19:37:04 +07:00
|
|
|
// Delete cache
|
|
|
|
// client._interactionCache.delete(data.nonce);
|
2022-04-16 17:44:43 +07:00
|
|
|
};
|