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")
)
}
});
}
}
这是我的代码。
每当我输入 -warnings user
并且用户没有警告时,它会在应该回复 user's warn
时回复 This user has no warnings
。我的另一个问题是如何让机器人在用户说 -warnings
时显示用户的警告,它显示当前用户的警告,意思是说 -warnings
的用户。