So this is probably just me being stupid and forgetting something small but I’ve spent like 13 hours trying to fix this, so when a person joins the server mongodb is meant to kinda like make a economy profile for them and save it (contains: money, userid, bank amount) its for my server economy system. Currently nothing get’s saved except for a blank value named "_id". My code is below. (and yes it’s connecting to mongodb correctly) Any help would be appreceated.
the code below is the stuff in my bot.js file and the one below it is "profileSchema.js"
module.exports = async(client, discord, member) =>{
let profile = await profileModel.create({
userID: member.id,
serverID: member.guild.id,
coins: 100,
bank: 0
});
profile.save();
}
const profileSchema = new mongoose.Schema({
userID: { type: String, require: true, unique: true},
serverID: { type: String, require: true },
coins: { type: Number, default: 100 },
bank: { type: Number }
})
const model = mongoose.model('ProfileModels', profileSchema);
module.exports = model;
2
Answers
Can you try once with the following code?
I don’t know how do you call your
member.id
, but try to do:And I hope have your
member.id
called asmessage.author
or something.and what is
member.guild.id
tho? since youruserID
is a member. Are you trying to call:message.author.guild.id
formember.guild.id
? We really don’t know. Can you show more of your code?