i want to make command that can give me information about someone that i mention like !info @Someone
i try code below, but didnt work.
This is the schema
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const profileSchema = new Schema({
_id: mongoose.Schema.Types.ObjectId,
userID: String,
nickname: String,
ar: Number,
server: String,
uid: Number,
});
module.exports = mongoose.model("User", profileSchema);
and this is what i try, but show nothing, didnt show any error sign.
client.on("message", async msg => {
let member = msg.mentions.users.first().username
if (msg.content === `!info @${member}`){
userData = await User.findOne({userID : msg.mentions.users.first().id});
if (userData) {
const exampleEmbed = new MessageEmbed()
.setColor('#808080')
.setTitle('Data Member')
.setDescription(`**Nickname :** ${userData.nickname}n**Adventure Rank :** ${userData.ar}nServer: ${userData.server}n**User ID :** ${userData.uid}`)
.setThumbnail(msg.author.avatarURL())
msg.reply({ embeds: [exampleEmbed] });
} else{
msg.reply("Please registration first")
}
}
}
);
3
Answers
Going through your code, I found these errors.
first of all you need members not users in
message.mentions.members.first()
.Second of all, you need to define
UserData
first likeconst UserData = ...
Let me know if it works after fixing these errors.
Also
message
event is depricated so try usingMessageCreate
instead from now onChange the
if
condition. How Discord Mentions WorkFor example:
By seeing your code, it might shuffle all of your
.first()
lets modify your code.