I'm trying to read when one of my users bumps the server with discous or disboard
client.on("messageCreate", async (message) => {
const guildId = message.guild.id;
const userId = message.interactionMetadata.user.id;
const messageType = message.interactionMetadata.type;
const bumpPoint = 1;
const member = await message.guild.members.fetch(userId);
const nickname = member.nickname;
//console.log(messageType);
//console.log(nickname);
const bumpExists = await userBumpDatabase.findOne({
guildId: guildId,
username: nickname
});
if (messageType === 2) {
if (!bumpExists) {
const newUser = new userBumpDatabase({
guildId: guildId,
username: nickname,
points: bumpPoint,
});
await newUser.save();
return message.reply({ content: `Added 1 point to ${nickname}`});
} else {
bumpExists.points += bumpPoint;
bumpExists.save()
return message.reply({ content: `Added 1 point to ${nickname}. They now have ${bumpExists.points} `});
}
}
});
I'm trying to reward users for bumping my server with discodus and disboard. If I comment out the messageType if loop and uncomment the 2 console.log commands the code executes perfectly and the data is logged correctly to the console.
Am I just overlooking something? using discord.js version 14.19.3