Closed fsrastdyyf closed 1 year ago
Hello! Thanks for submiting the issue, we will respond to you ASAP.
This can be fixed by copying function folder into your bot folder.
The bot directory structure would be like this.
Bot-name
├── function
├─ index.js
rest of directory
Hi, i was using this template, but when I send a message, the xp system gives an error (TypeError: Cannot read properties of undefined (reading 'getLevelingLevel') at C:\Users\Home\Desktop\dvstBot-main\index.js:81:44 at Client. (C:\Users\Home\Desktop\dvstBot-main\node_modules\@open-wa\wa-automate\dist\api\Client.js:803:92)
at Generator.next ()
at fulfilled (C:\Users\Home\Desktop\dvstBot-main\node_modules\@open-wa\wa-automate\dist\api\Client.js:28:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5))
/**
const getLevelingLevel = (userId, _dir) => { let pos = null let found = false Object.keys(_dir).forEach((i) => { if (_dir[i].id === userId) { pos = i found = true } }) if (found === false && pos === null) { const obj = { id: userId, xp: 0, level: 1 } _dir.push(obj) fs.writeFileSync('./database/user/level.json', JSON.stringify(_dir)) return 1 } else { return _dir[pos].level } }
/**
/**
/**
/**
// Cooldown XP gains to prevent spam const xpGain = new Set()
/**
/**
@param {string} userId */ const addCooldown = (userId) => {
if (!userId || typeof userId !== 'string') { return;}
xpGain.add(userId) setTimeout(() => { return xpGain.delete(userId) }, 60000) // Each minute }
module.exports = { getLevelingId, getLevelingLevel, getLevelingXp, addLevelingLevel, addLevelingXp, getUserRank, isGained, addCooldown }`
Index.js: `bot.onMessage(async message => {