discord-xp-typeorm
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

Discord XP Typeorm

This is a modified verison of discord-xp to work with typeorm.

Installation

NPM

npm i discord-xp-typeorm

Yarn

yarn add discord-xp-typeorm

Usage

This is a quick example of how DiscordXpTypeorm works!

const typeormXP = require("discord-xp-typeorm");
const typeorm = require("typeorm");
//Create your datasource or import an existing one
//So far only tested with sqlite
const DataSource = new typeorm.DataSource({
    type: "sqlite",
    database: "database.sqlite",
    synchronize: true,
    logging: false,
    entities: [typeormXP.Entity], //Required: use our level entity
    migrations: [],
    subscribers: [],
}).initialize();
const yourXP = new typeormXP();

yourXP.appendXp(
    "USER_SNOWFLAKE_ID", //The user Id
    "GUILD_SNOWFLAKE_ID", //The guild Id
    100 //The XP you wish to add
);
//boolean
yourXP.subtractXp(
    "USER_SNOWFLAKE_ID",
    "GUILD_SNOWFLAKE_ID",
    99
);
//boolean or typeormXP.Entity
yourXP.fetch(
    "USER_SNOWFLAKE_ID",
    "GUILD_SNOWFLAKE_ID"
);
//false or object:
//{
// userID: string,
// guildID: string,
// xp: number,
// cleanXp: any,
// level: number,
// position: any,
// lastUpdated: Date,
// cleanNextLevelXp: any
//}

Package Sidebar

Install

npm i discord-xp-typeorm

Weekly Downloads

7

Version

1.0.8

License

MIT

Unpacked Size

75.6 kB

Total Files

17

Last publish

Collaborators

  • turtlepaw