TypeError: Cannot read properties of undefined (reading 'has')

I'm trying to create a cooldown system for my bot following the official discordjs.guide page. When I run a command, I get the error you can read in the title. I'll post my interactionCreate in case the problem can be seen there https://pastebin.com/sZmuqYXt
Pastebin
const { Events, Collection } = require('discord.js');const client =...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
15 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Shiro
Shiro8mo ago
Alright node:events:492 throw er; // Unhandled 'error' event ^ TypeError: Cannot read properties of undefined (reading 'has') at Object.execute (C:\Users\angel\OneDrive\Escritorio\GL1TCH\src\events\interactionCreate.js:18:23) at Client.<anonymous> (C:\Users\angel\OneDrive\Escritorio\GL1TCH\src\index.js:39:51) at Client.emit (node:events:514:28) at InteractionCreateAction.handle (C:\Users\angel\OneDrive\Escritorio\GL1TCH\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12) at module.exports [as INTERACTION_CREATE] (C:\Users\angel\OneDrive\Escritorio\GL1TCH\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36) at WebSocketManager.handlePacket (C:\Users\angel\OneDrive\Escritorio\GL1TCH\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31) at WebSocketManager.<anonymous> (C:\Users\angel\OneDrive\Escritorio\GL1TCH\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12) at WebSocketManager.emit (C:\Users\angel\OneDrive\Escritorio\GL1TCH\node_modules@vladfrangu\async_event_emitter\dist\index.js:282:31) at WebSocketShard.<anonymous> (C:\Users\angel\OneDrive\Escritorio\GL1TCH\node_modules@discordjs\ws\dist\index.js:1173:51) at WebSocketShard.emit (C:\Users\angel\OneDrive\Escritorio\GL1TCH\node_modules@vladfrangu\async_event_emitter\dist\index.js:282:31) Emitted 'error' event on Client instance at: at emitUnhandledRejectionOrErr (node:events:395:10) at process.processTicksAndRejections (node:internal/process/task_queues:84:21) Node.js v18.17.1
treble/luna
treble/luna8mo ago
You didnt define client.cooldowns
Shiro
Shiro8mo ago
It is defined in the index.js file
treble/luna
treble/luna8mo ago
Show that file
Shiro
Shiro8mo ago
and trying to call it using const client = require('../index.js'); alright
treble/luna
treble/luna8mo ago
just use interaction.client?
Shiro
Shiro8mo ago
Pastebin
const Discord = require('discord.js');const fs = require('fs');cons...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Shiro
Shiro8mo ago
oh-
treble/luna
treble/luna8mo ago
I'm pretty sure if you use interaction.client (like yoy did before, dont see why you didn't do that for your cooldowns)
Shiro
Shiro8mo ago
how should I do it then? the collection is created in the index file
treble/luna
treble/luna8mo ago
read
Shiro
Shiro8mo ago
I tried but it gave the .has error anyways wait-
treble/luna
treble/luna8mo ago
did you save your index file
Shiro
Shiro8mo ago
k it was interaction.client I just put interaction the first time problem solved, thanks guys