Cooldown portion not working #1463
-
In the guide for cooldown it tells you to place the code in InteractionCreate with the assumption you followed the Command Handling portion. When you do this it gives an error that client is not defined due to this line When you look at the repository the code provided is in the index.js file and not in the interactionCreate file that was created during command handling portion. The question i have is what is the equivalent items for client in the interactionCreate.js file that was created? interactionCreated code below `const { Events } = require('discord.js'); module.exports = {
};` |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You just didnt define it |
Beta Was this translation helpful? Give feedback.
-
I have it figured out. when in the interactionCreate.js file ,that was created during the Command Handling portion of the guide, you need to have client changed to interaction.client. The git hub needs to be updated to reflect correctly. the link does not provide the interactionCreate.js file at all. Below is what the interactionCreate.js should look like after implementing the cooldown function. `const { Events, Collection } = require('discord.js'); module.exports = {
};` |
Beta Was this translation helpful? Give feedback.
I have it figured out. when in the interactionCreate.js file ,that was created during the Command Handling portion of the guide, you need to have client changed to interaction.client.
The git hub needs to be updated to reflect correctly. the link does not provide the interactionCreate.js file at all.
https://github.com/discordjs/guide/tree/main/code-samples/additional-features/cooldowns
Below is what the interactionCreate.js should look like after implementing the cooldown function.
`const { Events, Collection } = require('discord.js');
module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
if (!interaction.isChatInputCommand()) return;