#Bot command doesnt work

38 messages · Page 1 of 1 (latest)

tough cliffBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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!
torn yacht
#

how are you checking this in code?

#

yea how are you handling this command?

#

yes please
One of the suggestion i can already give to you is that you should not set properties in the embed if you dont know they exist beforehand.
For example, you should first check if you have a title before setting it into the embed, or that will throw errors aswell

whole ridge
#

also you can use getString() too

torn yacht
#

you just said the command doesnt work if not all options are passed

#

yea so you better check if you have a valid option before setting it into the embed first.

This is basically if(option.title) embed.setTitle()

#

im not saying this is going to solve your issue but it is one. Im still waiting for your code

#

thats why you shouldnt copy and paste the exact code someone gives you, i didnt give you code to copy and paste i just gave you an example

light lark
#

Because you didn’t define it

whole ridge
#

no

#

Its not gonna magically define itself

#

<Interaction>.options.getString('name')

#

getX basically, x being the type you expect

#

...

#

thats

#

how did you define option

#

You have to get your option, then check if its null or not

#

Not pull a variable out of thin air

#

Do what i said

#

this is basic js at this point

#

A variable isnt gonna magically assign itself

whole ridge
#

do you know basic js?

#

because this code really makes it looks like you dont

#

if(interaction.options.getX()) {
// do stuff
}

#

thats not gonna majke it work

#

and dont use var

#

no

#

use the code i sent

#

then replace X with whatever type you expect

#

probably getString

#

yep

#

thats indeed the expected bahaviour when you pass in an option

calm spade
torn yacht
#

we are trying to help you fix your own code here because you also said you dont have any errors in the console, so we cant pin point anything specifically for you to fix, so we are helping you fix things that we can tell are probably wrong

calm spade
#

Then you either have errors in your console or you catch and silently ignore them somewhere

torn yacht
#

the fact that you are not really getting an error when it "doesnt work" is kind of weird. But, one of the fixes is checking if the option exists before setting it on the embed, is the very first thing i told you. The fact that you dont really seem familiar with how to do that is not really helping us either sadly...