Skip to content
Advertisement

TypeError: Cannot read properties of undefined (reading ‘set’) discord.js v13 slash commands handler

I am creating a Slash commands handler when i run the bot i get this error : Mainguild.SlashCommands.set(SlashComanndsArray).then(async (SlashCommand) => { TypeError: Cannot read properties of undefined (reading 'set') this is the code :

JavaScript

also SlashComanndsArray , SlashCommand are defined and for the SlashCommands is a collection that i created id index.js with client.SlashCommands = new Collection(); the full code : https://srcb.in/BX1Ko4LuXd the index.js : https://srcb.in/qFC57vTaSn

Advertisement

Answer

  • Mainguild.SlashCommands is obviously undefined because Guild.SlashCommands is not a thing in discord.js
  • Use Guild#commands instead.
JavaScript
  • Your client.SlashCommands is limited to your client. You cannot use it with a Guild.
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement