#No embeds field

17 messages · Page 1 of 1 (latest)

hasty lily

Hi everyone, I'm trying to map messages from Discord.js to an array, but array field is missing, here is my function:

const embeds = () => {
            let array = [] as any[];
            m.embeds.forEach(e => {
                array.push({
                    author: {
                        name: e.author?.name,
                        iconURL: () => {
                            return e.author?.iconURL || null;
                        },
                        proxyIconURL: () => {
                            return e.author?.proxyIconURL || null;
                        },
                        url: e.author?.url || null
                    },
                    description: e.description || null,
                    fields: () => {
                        let fieldsembed = [] as any[];
                        e.fields.forEach(f => {
                            fieldsembed.push({
                                inline: f.inline,
                                name: f.name,
                                value: f.value
                            })
                        })
                        return fieldsembed;
                    },
                    footer: {
                        iconURL: e.footer?.iconURL,
                        proxyIconURL: e.footer?.proxyIconURL,
                        text: e.footer?.text
                    },
                    hexColor: e.hexColor || null,
                    image: {
                        proxyURL: e.image?.proxyURL,
                        url: e.image?.url
                    },
                    timestamp: e.timestamp,
                    thumbnail: {
                        proxyURL: e.thumbnail?.proxyURL,
                        url: e.thumbnail?.url
                    },
                    title: e.title || null,
                    url: e.url || null
                })
            })
        };

Every other field is there, can you help me?

I know i'm missing a dumb thing but idk what

empty shard

Also, is there a reason you're avoiding const array = m.embeds ?

hasty lily

yeah

to turn in in an array

empty shard

Message#embeds is already an array

hasty lily

wait

oh my bad

my bad thanks

so I have to json.stringify it right?

empty shard

Only if you need it to be a string

main jolt

Depends, what do you intend to do with it?

hasty lily

oups sorry for ping

empty shard

If you're saving it to a file, then it probably needs to be a string
If you're saving it in a local cache or a DB, it's probably fine to stay as an object

hasty lily

okay