#Adding options inside a SlashCommandBuilder

1 messages · Page 1 of 1 (latest)

warped tiger
#

module.exports.data = new SlashCommandBuilder()
.setName("ping")
.setDescription("Ping the user")
.addUserOption((option) => option.setName('user').setDescription('The user to boop').setRequired(true));

module.exports.run = (bot, interaction)  => {
  interaction.editReply ({
    content: "Pong"
  })
}
``` Having some trouble would appreciate the help
#

option is not appearing

odd pulsar
#

did you redeploy the commands?

warped tiger
#

what does that mean?

#

srry kinda trash at this

odd pulsar
#

how are you setting the commands

warped tiger
#

trough the slash-register?

#

or dis?

odd pulsar
#

ok, show that

warped tiger
odd pulsar
#

thats not it, that's receiving the interactions and executing the command

warped tiger
odd pulsar
#

show more of that

#

further down

warped tiger
odd pulsar
#

yes, thats it

warped tiger
#

alright

odd pulsar
#

did you run that?

warped tiger
#

pretty sure it runs automatically

odd pulsar
#

you need to run that everytime you update a commands options

#

and also, since you're using global commands, they might take up to an hour to update

warped tiger
#

oh dang

odd pulsar
#

you should use guild commands while testing

#

they update instantly

warped tiger
#

alright

#

ima do that

#

wait a sec

odd pulsar
warped tiger
#

not sure why im getting an error no dis

odd pulsar
#

you've made a syntax error

#

that ); is out of place

warped tiger
#

where should i put it then

odd pulsar
#

you need to close the try block, add a catch block, and then close the IIFE

#
(async () => {
  try {
    // stuff
  } catch (error) {
    // error happened
  }
})();
warped tiger
#

like this

odd pulsar
#

yep

warped tiger
#

alright still doesnt update tho

#

or atleast

#

nothing changes

odd pulsar
#

did those console.logs log anything

warped tiger
#

they stopped showing after i changed smth forgot what i changed

#

so no

#

they dont

odd pulsar
#

thats an issue on your end then, not something related to discord.js

warped tiger
odd pulsar
#

you're probably just not calling that function

#

or returning early

warped tiger
#

dont know what i should do cuz i got no idea

odd pulsar
#

add more console.log()s 😁

warped tiger
#

so basically debugging whole slash-register?

odd pulsar
#

sure

warped tiger
#

lol aight

#

its not getting passed if (updateCommands)

odd pulsar
#

and what's updateCommands?

warped tiger
#

well it starts here

#

wait

#

no

#

nvm

#

wrong

#

this

odd pulsar
#

and where are you executing that function

warped tiger
#

oh wait

#

i found problem

#

wait nvm

#

i dont even know where it executes

odd pulsar
#

search for the file path, you must be using require() with it on some other file

warped tiger
#

theres no require for the updateCommands

odd pulsar
#

is that the name of the file?

warped tiger
#

the things its suppose to require is the updateCommands right?

odd pulsar
#

no, thats the name of the parameter

warped tiger
#

so what needs to be required

odd pulsar
#

the file path

warped tiger
#

slash-register?

odd pulsar
#

if that's the file name, yes

warped tiger
#

index.js

odd pulsar
#

that () is executing the function, and you're not passing anything to it

warped tiger
#

oh right

odd pulsar
#

which means the updateCommands parameter will be undefined

warped tiger
#

sh**

#

um

#

so i add updateCommands inside of ()

#

?

odd pulsar
#

no, add true

warped tiger
#

alright

#

works

#

so um now theres 2 commands

#

1 with user argument and 1 without

odd pulsar
#

yeah, the one without is the global command

warped tiger
#

oh so can i remove it somehow?

odd pulsar
#

the up to date one is the guild command

#

client.application.commands.set([])

#

however, as i said previously, it might take up to an hour to update

warped tiger
#

alright so if i add bot to another server the global one will be gone?

odd pulsar
#

no

#

the global commands are global

#

guild commands are guild specific