TypeError Cannot read properties of undefined (reading 'toJSON')

TypeError: Cannot read properties of undefined (reading 'toJSON') at Object.<anonymous> (C:\Users\luizs\Documents\Bot\deploy-commands.js:12:29) at Module._compile (node:internal/modules/cjs/loader:1159:14) at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) at Module.load (node:internal/modules/cjs/loader:1037:32) at Module._load (node:internal/modules/cjs/loader:878:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47
13 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Squid
Squid3y ago
One of your command files is missing its data property with a slash command builder
Ashura
AshuraOP3y ago
would u tell me what do i need to do ? been struggling with these since 1pm
Squid
Squid3y ago
The error will be in one of the files in your /commands directory
Ashura
AshuraOP3y ago
but its saying its in the deploying-commands.js
Squid
Squid3y ago
You're accessing the property command.data (which is undefined) in that file command is defined as a separate file, and you should find that
Ashura
AshuraOP3y ago
if i send u a print maybe u could identify it for me ? im new at programing
const { SlashCommandBuilder ,ActionRowBuilder, ButtonBuilder , EmbedBuilder , Events } = require('@discordjs/builders');
const { MessageEmbed , ButtonStyle} = require("discord.js")

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('Cria uma ficha de Breed')
.addStringOption(option => option.setName('dinoname').setDescription('Dino que sera breedado').setRequired(true)),
async execute(interaction) {
await interaction.reply(
embed = new EmbedBuilder()
.setTitle(`\`${dinoname}\` Line`)
.setDescription(`Selecione os status breedados \`${dinoname}\``)
.setColor("#f20505"),
row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('health')
.setLabel('Health')
.setStyle (ButtonStyle.Secondary)
.setEmoji('1045048019285966848'),
new ButtonBuilder()
.setCustomId('stamina')
.setLabel('Stamina')
.setStyle(ButtonStyle.Secondary)
.setEmoji('1045048216753819709'),
new ButtonBuilder()
.setCustomId('melee')
.setLabel('Melee')
.setStyle(ButtonStyle.Secondary)
.setEmoji('1045048217982738553'),
new ButtonBuilder()
.setCustomId('continue')
.setLabel('Continuar')
.setStyle(ButtonStyle.Success)
.setEmoji('1045430134192222220'),
new ButtonBuilder()
.setCustomId('cancelar')
.setLabel('Cancelar')
.setStyle(ButtonStyle.Danger)
.setEmoji('1045430320993931274'),
)


)
},
};
const { SlashCommandBuilder ,ActionRowBuilder, ButtonBuilder , EmbedBuilder , Events } = require('@discordjs/builders');
const { MessageEmbed , ButtonStyle} = require("discord.js")

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('Cria uma ficha de Breed')
.addStringOption(option => option.setName('dinoname').setDescription('Dino que sera breedado').setRequired(true)),
async execute(interaction) {
await interaction.reply(
embed = new EmbedBuilder()
.setTitle(`\`${dinoname}\` Line`)
.setDescription(`Selecione os status breedados \`${dinoname}\``)
.setColor("#f20505"),
row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('health')
.setLabel('Health')
.setStyle (ButtonStyle.Secondary)
.setEmoji('1045048019285966848'),
new ButtonBuilder()
.setCustomId('stamina')
.setLabel('Stamina')
.setStyle(ButtonStyle.Secondary)
.setEmoji('1045048216753819709'),
new ButtonBuilder()
.setCustomId('melee')
.setLabel('Melee')
.setStyle(ButtonStyle.Secondary)
.setEmoji('1045048217982738553'),
new ButtonBuilder()
.setCustomId('continue')
.setLabel('Continuar')
.setStyle(ButtonStyle.Success)
.setEmoji('1045430134192222220'),
new ButtonBuilder()
.setCustomId('cancelar')
.setLabel('Cancelar')
.setStyle(ButtonStyle.Danger)
.setEmoji('1045430320993931274'),
)


)
},
};
@squiddleton
Squid
Squid3y ago
We expect you to have a solid grasp of JS fundamentals, re: #rules 2
Ashura
AshuraOP3y ago
pls bro tell me , its been more than 7 hours im trying to do only this command
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Squid
Squid3y ago
Because you can't directly send a builder instance to the API They're using the handler from the guide
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ashura
AshuraOP3y ago
im still learning js , so i cant understand that much and @migtibincoski , if u want to talk in the private about it , im also brazilian , id aprecciate if u could help me
Want results from more Discord servers?
Add your server