Corsy
DIAdiscord.js - Imagine an app
•Created by Corsy on 6/9/2024 in #djs-questions
level up message
so I am having an issue with the level up message not sending... the console doesn't throw and errors or anything so I am just confused why it doesn't send a levelup message
const newExp = await DatabaseHelper.addMemberExp(
message.author.id,
PER_MESSAGE
);
if (newExp && message.member) {
logger.info(
`Added exp to ${message.author.username} - they now have ${newExp}`
);
await ExperienceHelper.ensureUserHasLevelRoles(
message.member,
ExperienceHelper.getLevel(newExp)
);
if (
ExperienceHelper.getLevel(newExp - PER_MESSAGE) <
ExperienceHelper.getLevel(newExp)
) {
const spamCh = message.guild?.channels.cache.get(levelupChannel);
console.log(`spamCh: ${spamCh}`);
console.log(`spamCh type: ${spamCh?.type}`);
if (spamCh) {
if (spamCh.type === "GUILD_TEXT") {
spamCh.send({
content: `Hey ${message.author.toString()}, you've leveled up! You are now level ${ExperienceHelper.getLevel(
newExp
)}`,
});
} else {
console.error("Level up channel is not a text channel.");
}
} else {
console.error("Level up channel not found.");
}
}
}
}
const newExp = await DatabaseHelper.addMemberExp(
message.author.id,
PER_MESSAGE
);
if (newExp && message.member) {
logger.info(
`Added exp to ${message.author.username} - they now have ${newExp}`
);
await ExperienceHelper.ensureUserHasLevelRoles(
message.member,
ExperienceHelper.getLevel(newExp)
);
if (
ExperienceHelper.getLevel(newExp - PER_MESSAGE) <
ExperienceHelper.getLevel(newExp)
) {
const spamCh = message.guild?.channels.cache.get(levelupChannel);
console.log(`spamCh: ${spamCh}`);
console.log(`spamCh type: ${spamCh?.type}`);
if (spamCh) {
if (spamCh.type === "GUILD_TEXT") {
spamCh.send({
content: `Hey ${message.author.toString()}, you've leveled up! You are now level ${ExperienceHelper.getLevel(
newExp
)}`,
});
} else {
console.error("Level up channel is not a text channel.");
}
} else {
console.error("Level up channel not found.");
}
}
}
}
38 replies