UNPKG

level-system-phoenix

Version:

Ein Levelsystem für WhatsApp Bots mit Baileys und Command-Handlern inklusive Cheat-Schutz, XP, Ränge und Speicher.

24 lines (22 loc) 683 B
const Storage = require('./storage'); const LevelLogic = require('./level'); class LevelSystem { constructor(options = {}) { this.storage = new Storage(options.dataFile); this.logic = new LevelLogic(options); } processCommand(userId) { const now = Math.floor(Date.now() / 1000); const user = this.storage.getUser(userId); const result = this.logic.processXP(user, now); this.storage.updateUser(userId, user); return result; } getUser(userId) { return this.storage.getUser(userId); } getLevelName(level) { return this.logic.getLevelName(level); } } module.exports = LevelSystem;