Skip to content

Commit

Permalink
Truncate level up messages if over 10 levelers
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism committed Jan 12, 2021
1 parent 73d0c2a commit c192220
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/structures/game_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,12 @@ export default class GameSession {

// send level up message
if (leveledUpPlayers.length > 0) {
const message = leveledUpPlayers.map((leveledUpPlayer) => `${this.scoreboard.getPlayerName(leveledUpPlayer.userId)} has leveled from \`${leveledUpPlayer.startLevel}\` to \`${leveledUpPlayer.endLevel} (${getRankNameByLevel(leveledUpPlayer.endLevel)})\``)
.join("\n");
sendInfoMessage({ channel: this.textChannel }, "Power up!", message);
let levelUpMessages = leveledUpPlayers.map((leveledUpPlayer) => `\`${this.scoreboard.getPlayerName(leveledUpPlayer.userId)}\` has leveled from \`${leveledUpPlayer.startLevel}\` to \`${leveledUpPlayer.endLevel} (${getRankNameByLevel(leveledUpPlayer.endLevel)})\``);
if (levelUpMessages.length > 10) {
levelUpMessages = levelUpMessages.slice(0, 10);
levelUpMessages.push("and many others...");
}
sendInfoMessage({ channel: this.textChannel }, "🚀 Power up!", levelUpMessages.join("\n"));
}

// commit guild stats
Expand Down Expand Up @@ -545,7 +548,7 @@ export default class GameSession {
}

/**
* https://www.desmos.com/calculator/y8kweubkqs
* https://www.desmos.com/calculator/zxvbuq0bch
* @param guildPreference - The guild preference
* @returns The amount of EXP gained based on the current game options
*/
Expand Down

0 comments on commit c192220

Please sign in to comment.