#Undefined interaction.client.commands.get()

13 messages · Page 1 of 1 (latest)

sour mural
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

hot tulip
#

sounds like you never defined client.commands

#

that's where you defined command

#

<Client>.commands is not a native property of the Client class

#

it's commonly defined, but still one that you'd need to define yourself

#

your error is "Cannot read properties of undefined (reading 'get')" which means that it's reading get from undefined
not that get is undefined

onyx lightBOT
#

ReferenceError: "x" is not defined: learn more
TypeError: Cannot read properties of undefined/null (reading "x"): learn more

#

• The provided id is incorrect (copy role ids from context menus, not message mentions)
• The client does not have this structure cached (try fetching instead)
• The client is not yet ready (move the code into any event listener callback)

hot tulip
#

whoops, disregard the second one

#

well you'd probably want to define it before you receive an interaction rather than every time you receive an interaction

onyx lightBOT
#

guide Creating Your Bot: Loading command files
read more

hot tulip
#

then can you show where client.commands = new Collection(); is?

#

then please read the guide again