March 7th 3c2b4c9364 fix: Cannot read properties of undefined (reading 'guildId')
TypeError: Cannot read properties of undefined (reading 'guildId')
    at module.exports [as INTERACTION_SUCCESS]
2022-10-11 17:19:57 +07:00

30 lines
871 B
JavaScript

'use strict';
const { Events } = require('../../../util/Constants');
module.exports = (client, { d: data }) => {
/**
* Emitted whenever client user send interaction and success
* @event Client#interactionSuccess
* @param {InteractionResponseBody} data data
*/
client.emit(Events.INTERACTION_SUCCESS, data);
// Get channel data
const cache = client._interactionCache.get(data.nonce);
if (!cache) return;
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_,
});
// Delete cache
// client._interactionCache.delete(data.nonce);
};