Content/map is undefined

86
January 27, 2022, at 12:40 PM

Let's say I have this:

 const db = require('../../Models/warns')
const { Message, MessageEmbed } = require('discord.js')
const reason = args.slice(1).join(" ")
            db.findOne({ guildid: message.guild.id, user: user.user.id}, async(err, data) => {
                if(err) throw err;
                if(!data) {
                    data = new db({
                        guildid: message.guild.id,
                        user : user.user.id,
                        content : [
                            {
                                moderator : message.author.id,
                                reason : reason
                            }
                        ]
                    })
                } else {
                    const obj = {
                        moderator: message.author.id,
                        reason : reason
                    }
                    data.content.push(obj)
                }
                data.save()
            });

Why is push undefined (TypeError: Cannot read properties of undefined (reading 'push'))? Is there anything I am missing?

Same thing goes if I have this:

const sembed = new MessageEmbed()
                    .setTitle(`${user.user.tag}'s warns`)
                    .setDescription(
                        data.content.map(
                            (w, i) => 
                            `\`${i + 1}\` | Moderator : ${message.guild.members.cache.get(w.moderator).user.tag}\nReason : ${w.reason}`
                        )
                    )
                    .setColor("BLUE")
                message.channel.send({ embeds: [sembed] });

map is also undefined.

(I am using discordjs v13)

Models/warns:

const { Schema, model } = require('mongoose');
module.exports = model("warns", new Schema({
  userId: String,
  guildId: String,
  moderatorId: String,
  reason: String,
  timestamp: Number,
})
);

NOTE: This code is by using mongoose npm package (A database, pretty much like quick.db but better)

READ ALSO
springboot mvc log request body string(in Filter) before RestController

springboot mvc log request body string(in Filter) before RestController

I know basics of springboot mvc but don't well understand how the underlying classes work(such as Servlet, Intercepters, Filters)Searched but didn't find answer

66
How can I capture the error thrown by a python script in the bash script calling it?

How can I capture the error thrown by a python script in the bash script calling it?

I want to write a bash script that sends a message depending on whether a python script it called ran successfully or threw an error

68
Can I get original page be different than the AMP?

Can I get original page be different than the AMP?

So I am using IFRAME on my pagesThe code usually goes like this

73
Where PWA store photos?

Where PWA store photos?

I've the PWA app, launched on Android deviceThe app allow to take pictures and upload them to server

106