Guys pls someone help me with this i am writing i wanna put slash commands to my bot but i cant

TypeError: Cannot read properties of undefined (reading 'cache') its discord.js v14 const guild = client.guild.cache.get(guildId) if (!guild) { console.error(Guild with the ${guild} was not found); } guild.commands.set(commands).catch((error => { console.error(error setting commands for guild ${guild.name} (${guild.id}):, error); })); } client.on('interactionCreate', async (Interaction) => { try { if(Interaction.CommandName === 'mimic') { const mimic = interaction.options.getString('say'); await interaction.reply(you said: \n${mimic}); } } catch (error) { console.error(error); } })
18 Replies
d.js toolkit
d.js toolkit10mo 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!
treble/luna
treble/luna10mo ago
its client.guilds
PAIDODAMASTIS
PAIDODAMASTISOP10mo ago
it work but now its saying this error setting commands for guild Ghost RolePlay (842396705207091220): DiscordAPIError[50035]: Invalid Form Body 0.options[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (5, 4, 11, 2, 3, 7, 9, 8, 10, 6, 1).
treble/luna
treble/luna10mo ago
One of your command options doesnt have a type and dont deploy your commands on startup Use the separate rest script
d.js docs
d.js docs10mo ago
guide Creating Your Bot: Registering slash commands read more
PAIDODAMASTIS
PAIDODAMASTISOP10mo ago
what do you mean saperate rest script
treble/luna
treble/luna10mo ago
.
PAIDODAMASTIS
PAIDODAMASTISOP10mo ago
how do i fix that oh ok
treble/luna
treble/luna10mo ago
by specifying a type, and also showing the actual code
PAIDODAMASTIS
PAIDODAMASTISOP10mo ago
i saw it what do you mean specifiyng a type i am new to djs
d.js docs
d.js docs10mo ago
guide Home: What's new read more
treble/luna
treble/luna10mo ago
then please read the guide and docs
PAIDODAMASTIS
PAIDODAMASTISOP10mo ago
ok i write the deployment script in the deploy-commands.js right?
treble/luna
treble/luna10mo ago
yes
PAIDODAMASTIS
PAIDODAMASTISOP10mo ago
does the deploy command file need to be in a commands folder? it says that it cant find the module
treble/luna
treble/luna10mo ago
it expects you to have your commands in subfolders yes you can adjust the path to your environment
PAIDODAMASTIS
PAIDODAMASTISOP10mo ago
ok so i created a commands folder and i put the file there and now how do i adjust the path do i const it on index.js ?
treble/luna
treble/luna10mo ago
you edit the path in your code or you make a commands folder with subfolders
Want results from more Discord servers?
Add your server