Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Content/map is undefined

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)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!