How do I add fields to message embed objects?
I have this code: https://srcb.in/nDh1ScQ8Oz
I am trying to do
report2.addField
and it isn't working. It is saying
I have no idea why.18 Replies
what is report2
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
its object not class
Alright so If I want to do this I have to do
new MessageEmbed()
right?Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
btw addField except objrct not array ( u mean addFields)
look at tags v13
not v14
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
main is v14 #djs-in-dev-version
stable v13
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
stable is still outdated
Okay, so I am having issues with this line now:
const url = message.attachments.first().url || 'no';
It either passes the URL (if it is first like this) or if I have it like this const url = 'no' || message.attachments.first().url;
It only passes no
it is like the OR ||
is not working.
Do I need to use an if statement instead?'no' is true so it alwys be
also .first().url will make error if .first() is undefined
Yeah, so if there isn't an attachment I want
url
to be no
if there is I want it to have the attachment's URL
Using an IF statment doesn't work. Optional chaining (?.)
The optional chaining operator (?.) enables you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid.
just add it after .first() and it should work
I knew I was missing something. Thank you!