#TypeError Cannot read properties of undefined (reading options)

1 messages · Page 1 of 1 (latest)

kind crag
#

@shell lily here

shell lily
#
const CommandDirectory = fs.readdirSync("./commands").filter(file => file.endsWith(".js"));
const commands = [];

client.commands = new Collection();

for (const file of CommandDirectory) {
    const command = require(`./commands/${file}`);
    commands.push(command.data.toJSON());
    client.commands.set(command.data.name, command);
}```
kind crag
#

no, your interactionCreate event is what I meant

shell lily
#

client.on("interactionCreate", async Interaction => {
    if (!Interaction.isCommand()) return;

    const command = client.commands.get(Interaction.commandName);
    
    if (!command) return;

    try {
        await command.execute(Interaction);
    } catch(err) {
        if (err) console.error(`${ErrorLog}${err}`);
    }
})```
kind crag
#

can you remove the try catch for now so it logs the full error

shell lily
#

i did that and now i get no logs

#

it just says The application did not respond

#

oh wait

#

i removed execute

kind crag
#

that would be a way to remove the error too KEKW

shell lily
#
            await interation.followUp(`${interation.data.options[0]}`);
                                                         ^

TypeError: Cannot read properties of undefined (reading 'options')```
kind crag
#

oh how did I miss that

shell lily
#

i get that error when i remove the try and catch

kind crag
#

what are you trying to print there

shell lily
#

the option they add on the slash command

#

/command blah

kind crag
#

a specific option or just the first

shell lily
#

the first

kind crag
#

can you log interaction.options.data

shell lily
#

i will try

#
            await console.log(`${interation.data.options[0]}`);
                                                 ^

TypeError: Cannot read properties of undefined (reading 'options')```
kind crag
#

before that

#

wait

#

thats not what I told you to log meguFaceReverse

shell lily
#

it works i think if i put the .data.options on just reply

#

but if i do followup it wont

kind crag
#

can you log interaction.options.data

#

interaction.data isn't a thing

shell lily
#

oh

#

it just shows [object Object]

kind crag
#

console.log(interaction.options.data)

#

by putting it in a string you are not logging it properly

shell lily
#

[ { name: 'input', type: 'STRING', value: 'djdj' } ]

kind crag
#

interaction.options.data[0] it is then

shell lily
#

thanks

kind crag
#

do you want to print the value of the option?

#

cuz printing the option as a string will print object Object

shell lily
#

i just need to read the value

#

then send it to a local web api

kind crag
#

then also call .value on it

shell lily
#

ALRIGHT

#

ah

#

caps

#

but thanks

kind crag
#

DONT YELL AT ME

shell lily
#

i bumped it

kind crag
#

no problem