diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/extensions/BotClient.ts | 15 | ||||
-rw-r--r-- | src/lib/models/Level.ts | 21 | ||||
-rw-r--r-- | src/lib/models/index.ts | 1 |
3 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/extensions/BotClient.ts b/src/lib/extensions/BotClient.ts index 547d0eb..7ac0051 100644 --- a/src/lib/extensions/BotClient.ts +++ b/src/lib/extensions/BotClient.ts @@ -243,6 +243,21 @@ export class BotClient extends AkairoClient { }, { sequelize: this.db } ); + Models.Level.init( + { + id: { + type: DataTypes.STRING, + primaryKey: true, + allowNull: false + }, + xp: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: 0 + } + }, + { sequelize: this.db } + ); try { await this.db.sync({ alter: true }); // Sync all tables to fix everything if updated } catch { diff --git a/src/lib/models/Level.ts b/src/lib/models/Level.ts new file mode 100644 index 0000000..bce9aa4 --- /dev/null +++ b/src/lib/models/Level.ts @@ -0,0 +1,21 @@ +import { Optional } from 'sequelize/types'; +import { BaseModel } from './BaseModel'; + +export interface LevelModel { + id: string; + xp: number; +} + +export type LevelModelCreationAttributes = Optional<LevelModel, 'xp'>; + +export class Level extends BaseModel<LevelModel, LevelModelCreationAttributes> { + public id: string; + public xp: number; + get level(): number { + return Level.convertXpToLevel(this.xp); + } + static convertXpToLevel(xp: number): number { + // WIP + return 0; + } +} diff --git a/src/lib/models/index.ts b/src/lib/models/index.ts index ef65415..8eb817e 100644 --- a/src/lib/models/index.ts +++ b/src/lib/models/index.ts @@ -2,3 +2,4 @@ export * from './BaseModel'; export * from './Guild'; export * from './Ban'; export * from './Modlog'; +export * from './Level'; |