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

220
Views
Discord.js check warnings command bug
const Mongodb = require('../../models/modSchema');
const Discord = require('discord.js');

module.exports = {
    name: 'warnings',
    category: "moderation",
    description: 'Finds and displays the warnings of the mentioned user.',
    run : async(client, message, args, db) => {
        const mentionedMember = message.mentions.members.first() || message.guild.members.cache.get(args[0]);

        if(!mentionedMember) return message.channel.send("bruh mention a member u nub");

        Mongodb.find({ guildId : message.guild.id, userId : mentionedMember.user.id}, async(err, data) => {
            if(err) throw err;
            if(data) {
                message.channel.send(new Discord.MessageEmbed()
                    .setTitle(`${mentionedMember.user.tag}'s punishments.`)
                    .addFields(
                        data.map((warn)=> {
                            if (!warn || warn === undefined) return { name: 'Punishments', value: 'This user has no punishments' };
                            if (warn) return { name: `Case #${warn.case} - ${warn.punishType}`, value: warn.reason};
                        })
                    )
                    .setColor("GREEN")
                )
            } 
        });
    }
}

This is my code. Whenever I type -warnings user and the user has no warns then it replies with user's warn when it's supposed to reply with This user has no warnings. Another question I have is how to make the bot show the user's warnings when the user says -warnings it shows the current user's warnings meaning that the user that said -warnings.

over 4 years ago · Santiago Trujillo
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!