@@ -43,13 +43,13 @@ export class LevelingService {
4343 this . updateUserCooldown ( userId ) ;
4444 }
4545
46- public async getStats ( userId : string ) : Promise <
46+ public async getStats ( userId : string , username : string ) : Promise <
4747 UserData & {
4848 stats : UserStats ;
4949 requiredXP : number ;
5050 }
5151 > {
52- const user = await this . getOrCreateUser ( userId ) ;
52+ const user = await this . getOrCreateUser ( userId , username ) ;
5353 const stats = await this . calculateUserStats ( user ) ;
5454
5555 return {
@@ -78,7 +78,7 @@ export class LevelingService {
7878 }
7979
8080 private async processMessageXP ( message : Message < true > ) : Promise < void > {
81- const user = await this . getOrCreateUser ( message . author . id ) ;
81+ const user = await this . getOrCreateUser ( message . author . id , message . author . username ) ;
8282 const earnedXP = this . generateXP ( ) ;
8383 const { newLevel, totalXP } = this . calculateXPAndLevel ( user , earnedXP ) ;
8484
@@ -140,10 +140,10 @@ export class LevelingService {
140140 // });
141141 }
142142
143- private async getOrCreateUser ( userId : string ) : Promise < UserData > {
143+ private async getOrCreateUser ( userId : string , username : string ) : Promise < UserData > {
144144 const user = await this . userService . getUser ( userId ) ;
145145
146- return user ?? ( await this . userService . createUser ( { id : userId } ) ) ;
146+ return user ?? ( await this . userService . createUser ( { id : userId , username } ) ) ;
147147 }
148148
149149 private async calculateUserStats ( user : UserData ) : Promise < UserStats > {
0 commit comments