I'm making a RPG bot for Discord, and a main part of it is the leveling system. All mathematical systems work, but the message for it (wierdly enough) doesn't. Code:
levelUpFunc = function() {
if (level.exp >= level.lvlupreq) {
level.lvl += 1;
level.lvlupreq += level.lvl;
level.lvlupreq *= 2.5;
level.exp = 0;
message.channel.send(`You levelled up to **level ${level.lvl}**! +5 Hp, +1 Atk, +1 Def`);
}
};
let checkForLvlup = setInterval(() => levelUpFunc(), 500);
And the console returns:
ReferenceError: message is not defined
This is not the case with all other message.channel.send();
.
Please help!
You didn't define message
in the snippet you posted. We would need to see more code to tell you where message is defined. But likely you could add message
as a parameter of levelUpFunc, and then call it with levelUpFunc(message)
, assuming that message
is defined wherever you call this function from.