From fcd2184df8448ac9359d715318b89c83fd90199a Mon Sep 17 00:00:00 2001 From: Hexugory Date: Sat, 1 Apr 2023 00:03:00 -0500 Subject: [PATCH] that better work --- src/cbclient.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/cbclient.ts b/src/cbclient.ts index e0fad34..b3f4c96 100644 --- a/src/cbclient.ts +++ b/src/cbclient.ts @@ -35,13 +35,17 @@ export class ActiveBattle { this.rounds++; const outcome = this.battle.simulateRound(); const log = this.battle.log.slice(0, 1024); + + if (this.battle.channel.isDMBased()) return; + const player1 = this.battle.channel.guild.members.resolve(this.battle.player1.user_id); + const player2 = this.battle.channel.guild.members.resolve(this.battle.player2.user_id); await this.message.edit({ embeds: [ new EmbedBuilder() .addFields([ - { name: 'Team 1', value: `${this.battle.team1[0].character.name} [${this.battle.team1[0].health}]\n${this.battle.team1[1].character.name} [${this.battle.team1[1].health}]\n${this.battle.team1[2].character.name} [${this.battle.team1[2].health}]`, inline: true }, - { name: 'Team 2', value: `${this.battle.team2[0].character.name} [${this.battle.team2[0].health}]\n${this.battle.team2[1].character.name} [${this.battle.team2[1].health}]\n${this.battle.team2[2].character.name} [${this.battle.team2[2].health}]`, inline: true }, + { name: player1?.user.username || '████████', value: `${this.battle.team1[0].character.name} [${this.battle.team1[0].health}]\n${this.battle.team1[1].character.name} [${this.battle.team1[1].health}]\n${this.battle.team1[2].character.name} [${this.battle.team1[2].health}]`, inline: true }, + { name: player2?.user.username || '████████', value: `${this.battle.team2[0].character.name} [${this.battle.team2[0].health}]\n${this.battle.team2[1].character.name} [${this.battle.team2[1].health}]\n${this.battle.team2[2].character.name} [${this.battle.team2[2].health}]`, inline: true }, { name: 'Log', value: log } ]) .setColor(0x8c110b) @@ -53,11 +57,8 @@ export class ActiveBattle { this.battle.client.ACTIVE_BATTLES.splice(this.battle.client.ACTIVE_BATTLES.indexOf(this), 1); - if (this.battle.channel.isDMBased()) return; let elo1 = this.battle.player1.elo; let elo2 = this.battle.player1.elo; - const player1 = this.battle.channel.guild.members.resolve(this.battle.player1.user_id); - const player2 = this.battle.channel.guild.members.resolve(this.battle.player2.user_id); switch (outcome) { case BattleState.Team1Win: @@ -149,14 +150,19 @@ export class CBClient extends CommandClient { await Unit.findOne({ where: { id: challenge.player2.slot2 || -1 } }) || defaultUnit, await Unit.findOne({ where: { id: challenge.player2.slot3 || -1 } }) || defaultUnit ] + + if (challenge.message.channel.isDMBased()) return; + const player1 = challenge.message.channel.guild.members.resolve(challenge.player1.user_id); + const player2 = challenge.message.channel.guild.members.resolve(challenge.player2.user_id); + const battle = new Battle(this, int.channel, challenge.player1, challenge.player2, team1, team2); const activeBattle = new ActiveBattle(battle, await int.channel.send({ embeds: [ new EmbedBuilder() .addFields([ - { name: 'Team 1', value: `${battle.team1[0].character.name} [${battle.team1[0].health}]\n${battle.team1[1].character.name} [${battle.team1[1].health}]\n${battle.team1[2].character.name} [${battle.team1[2].health}]`, inline: true }, - { name: 'Team 2', value: `${battle.team2[0].character.name} [${battle.team2[0].health}]\n${battle.team2[1].character.name} [${battle.team2[1].health}]\n${battle.team2[2].character.name} [${battle.team2[2].health}]`, inline: true }, + { name: player1?.user.username || '████████', value: `${battle.team1[0].character.name} [${battle.team1[0].health}]\n${battle.team1[1].character.name} [${battle.team1[1].health}]\n${battle.team1[2].character.name} [${battle.team1[2].health}]`, inline: true }, + { name: player2?.user.username || '████████', value: `${battle.team2[0].character.name} [${battle.team2[0].health}]\n${battle.team2[1].character.name} [${battle.team2[1].health}]\n${battle.team2[2].character.name} [${battle.team2[2].health}]`, inline: true }, { name: 'Log', value: 'Starting...' } ]) .setColor(0x8c110b)