Arkasz
Arkasz
DIAdiscord.js - Imagine an app
Created by Tissemyren on 2/26/2024 in #djs-questions
I don't really understand the registering slash commands part of the guide
I'm also a noob, but what I understood till now is initializing slash commands (this is done by the deploy-command.js) for your bot in Discord is a separate process then running them (this is done in the index.js). Due to this you might initialize commands in a deploy-command.js, for which you don't have a function yet in index.js. So you could see the command in Discord, but it would throw an error if you click on it. The tutorial solves this elegantly by having the initialization code together with the executable code. This is why they run through the same folders. The deploy-commands uses the data: part of the slashcommandbuilder, and index.js the async execute(interaction) {} part. I hope I'm somewhat correct 😄 PS: my little struggle: if you want to change the initialization parameters for your slash command (for example: you addStringOptions in the data: part), then you will need to run deploy-commands.js for them to be visible in discord.
11 replies