#Defaults for object parameters

2 messages · Page 1 of 1 (latest)

sand eagle

I am trying to set the parameters to be optional with a default setup, I tried to make this but it shows cannot read properties of undefined (reading 'author')

client.embed = ({
        author = client.user,
    }) => {
        const embed = new EmbedBuilder()
        .setDescription("test")
        if (author) embed.setAuthor({ name: author.username })
        return embed
    }```
fair spruceBOT
  • 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!