UNPKG

@jiman24/discord-rpg

Version:

```bash $ npm install @jiman24/discord-rpg ```

43 lines (42 loc) 1.52 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const discord_js_commando_1 = require("discord.js-commando"); const sqlite_1 = require("sqlite"); const sqlite3_1 = __importDefault(require("sqlite3")); const crypto_1 = __importDefault(require("crypto")); class DiscordRPG extends discord_js_commando_1.Client { constructor(options) { super(options); this.registry.registerGroup("general").registerDefaults(); } // set sqlite3 database file async setDBFile(filename) { const db = await sqlite_1.open({ filename, driver: sqlite3_1.default.Database }); this.db = db; this.setProvider(new discord_js_commando_1.SQLiteProvider(db)); } // register a command registerCommand(info, cmd) { const id = crypto_1.default.randomUUID(); class Wrapper extends discord_js_commando_1.Command { constructor(client) { super(client, { description: "empty", group: "general", memberName: id, argsType: "multiple", ...info, }); } async run(msg, args) { cmd(msg, args); return null; } } this.registry.registerCommand(Wrapper); } } exports.default = DiscordRPG;