Slash

Error with my Slash command
15 Replies
d.js toolkit
d.js toolkit15mo ago
- 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!
Ichinose102
Ichinose102OP15mo ago
Hello, I need a little help because I have an error in the slashcommands. Here is the error: slashcommand[add${command.options[i].type.slice(0, 1).ToUpperCase() + command.options[i].type.slice(1, command.options[i].type.length)}Option](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required))
treble/luna
treble/luna15mo ago
thats not an error thats code also its .toUpperCase()
Ichinose102
Ichinose102OP15mo ago
I can not see the problem ToUpperCase in my code
treble/luna
treble/luna15mo ago
what? that code is really messy and invalid
d.js docs
d.js docs15mo ago
guide Creating Your Bot: Registering slash commands read more
treble/luna
treble/luna15mo ago
use that
Ichinose102
Ichinose102OP15mo ago
Does that mean I have to replace it with something else? const Discord = require('discord.js') const { REST } = require("@discordjs/rest") const { Routes } = require('discord.js') module.exports = async bot => { let commands = []; bot.commands.forEach(async command => { let slashcommand = new Discord.SlashCommandBuilder() .setName(command.name) .setDescription(command.description) .setDMPermission(command.dm) .setDefaultMemberPermissions(command.permissions === "Aucune" ? null : command.permissions) if (command.options?.length >= 1) { for (let i = 0; i < command.options.length; i++) { slashcommand[add${command.options[i].type.slice(0, 1).ToUpperCase() + command.options[i].type.slice(1, command.options[i].type.length)}Option](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required)) } } commands.push(slashcommand); }) const rest = new Discord.REST({ version: "10" }).setToken(bot.token) await rest.put(Routes.applicationCommands(bot.user.id), { body: commands }) console.log("Les commandes sont prêtes"); }
treble/luna
treble/luna15mo ago
the code above is pretty much unreadable and i dont see why you would use it because you can just use slashcommandbuilders, export them and call .toJSON() on them no need for this kind of magic
Ichinose102
Ichinose102OP15mo ago
XD simple and effective thanks I’m sorry but I’m really struggling to Thonk
treble/luna
treble/luna15mo ago
understand what
Ichinose102
Ichinose102OP15mo ago
this part
treble/luna
treble/luna15mo ago
You should know how to import and export stuff
Ichinose102
Ichinose102OP15mo ago
Well I didn’t have config.json before
treble/luna
treble/luna15mo ago
use what you have whether its dotenv or a json config Not really djs related
Want results from more Discord servers?
Add your server