Error with slash command
I get error addSubcommand(command => command.setName('add').setDescription('Add a reaction role to a message.').addStringOption(option => option.setName('message-id').setDescription('The message to react to.').setRequired(true).addStringOption(option => option.setName('emoji').setDescription('The emoji to react with.').setRequired(true)).addRoleOption(option => option.setName('role').setDescription('The role you want to give.').setRequired(true)))
^
TypeError: option.setName(...).setDescription(...).setRequired(...).addStringOption is not a function
at C:\Users\user\Documents\pj2 clan bot coded\commands\utility\reactionroles.js:8:222
at MixedClass._sharedAddOptionMethod (C:\Users\user\Documents\pj2 clan bot coded\node_modules\@discordjs\builders\dist\index.js:2381:50)
at MixedClass.addStringOption (C:\Users\user\Documents\pj2 clan bot coded\node_modules\@discordjs\builders\dist\index.js:2353:17)
at C:\Users\user\Documents\pj2 clan bot coded\commands\utility\reactionroles.js:8:106
at MixedClass.addSubcommand (C:\Users\user\Documents\pj2 clan bot coded\node_modules\@discordjs\builders\dist\index.js:2504:50)
at Object.<anonymous> (C:\Users\user\Documents\pj2 clan bot coded\commands\utility\reactionroles.js:8:6)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
with the code (only one snippet)
.addSubcommand(command => command.setName('add').setDescription('Add a reaction role to a message.').addStringOption(option => option.setName('message-id').setDescription('The message to react to.').setRequired(true).addStringOption(option => option.setName('emoji').setDescription('The emoji to react with.').setRequired(true)).addRoleOption(option => option.setName('role').setDescription('The role you want to give.').setRequired(true)))16 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- 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!
- ✅
Marked as resolved by staffok ty, ill try fixing
unexpected token )
.addSubcommand(command => command.setName('add').setDescription('Add a reaction role to a message.').addStringOption(option => option.setName('message-id').setDescription('The message to react to.').setRequired(true).addStringOption(option => option.setName('emoji').setDescription('The emoji to react with.').setRequired(true)))))
^
SyntaxError: Unexpected token ')'
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1178:20)
at Module._compile (node:internal/modules/cjs/loader:1220:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\user\Documents\pj2 clan bot coded\index.js:19:19)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
Where do you put it? I have JavaScript knowledge but it is not clear where to put it
Same error, unexpected token )
.addSubcommand(command => command.setName('add').setDescription('Add a reaction role to a message.').addStringOption(option => option.setName('message-id').setDescription('The message to react to.').setRequired(true)).addStringOption(option => option.setName('emoji').setDescription('The emoji to react with.').setRequired(true)).addRoleOption(option => option.setName('role').setDescription('The role you want to give.').setRequired(true)))
u sure abt that.
U just described add the bracket. When I add the bracket I get a syntax errorUnknown User•8mo ago
Message Not Public
Sign In & Join Server To View
I am not 'expecting my code to magically work'. I am simply asking a question that my code editor (VS Code) does not say where to put it and if you can help me put it there.
That's not very helpful is it 🤣
It shows me where but not how to fix it or where to put the extra bracket
🤣
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
TypeError: option.setName(...).setDescription(...).setRequired(...).addStringOption is not a function
VS Code says there are no problems but node does when I run node index.js
VSCode cannot run your code for you to display this error (though having an element of TypeScript can). You are trying to add a string option to another string option which is not something you can do. I'm aware others have pointed you towards how you're using your brackets, however that's really the only reason this is happening, you trying to chain a method to other methods that don't support it
Okay then, THIS is djs related help because in a normal node program it would of worked. How would I add another stringOption
Same thing you did with the first one, chain it onto your parent command
If you aren't comfortable using the builder methods, you can always take the approach of using the raw API JSON formats instead
Same error
:method: SlashCommandBuilder#addStringOption
@1.8.1
Adds a string option.
:method: SharedSlashCommandOptions#addStringOption @1.8.1
Adds a string option.How is this supposed to help
Well I'm not really sure what else to suggest other than giving you the information on what methods exist on what classes and what is returned from those methods
That's funny, you could just try and fix the code or point out the error. Not give some useless piece of info from the docs.
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
🤓 👆🏻 um, ackshully, this is very basic js
Bro this server has the worst moderation team lmfao
try muting me @Qjuh idiot, dosent know how to think nerd :discordnerd: