Skip to content

Commit

Permalink
update: current elo response (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustDams authored Jun 16, 2024
1 parent b39f9f9 commit 4d75587
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions commands/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Graph = require('../functions/graph')
const errorCard = require('../templates/errorCard')
const successCard = require('../templates/successCard')
const Interaction = require('../database/interaction')
const { getInteractionOption, getGameOption } = require('../functions/utility')
const { getInteractionOption, getGameOption, getCurrentEloString } = require('../functions/utility')

const getOptions = () => {
const options = structuredClone(Options.stats)
Expand Down Expand Up @@ -152,7 +152,7 @@ const sendCardWithInfo = async (
...head,
{ name: 'Highest Elo', value: playerLastStats['Highest Elo'].toString(), inline: true },
{ name: 'Lowest Elo', value: playerLastStats['Lowest Elo'].toString(), inline: true },
{ name: 'Current Elo', value: playerLastStats['Current Elo'].toString(), inline: true },
{ name: 'Current Elo', value: getCurrentEloString(playerLastStats), inline: true },
{ name: 'Games', value: `${playerLastStats.games} (${playerLastStats.winrate.toFixed(2)}% Win)`, inline: true },
{
name: 'Elo Gain',
Expand Down
2 changes: 1 addition & 1 deletion commands/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const buildEmbed = async ({
{ name: 'Games', value: `${playerStats.lifetime.Matches} (${playerStats.lifetime['Win Rate %']}% Win)`, inline: true },
{ name: 'K/D', value: playerStats.lifetime['Average K/D Ratio'], inline: true },
{ name: 'HS', value: `${playerStats.lifetime['Average Headshots %']}%`, inline: true },
{ name: 'Elo', value: playerLastStats['Current Elo'] ?? faceitElo.toString(), inline: true },
{ name: 'Elo', value: getCurrentEloString(playerLastStats), inline: true },
{ name: `:flag_${playerCountry.toLowerCase()}:`, value: ladderCountry.position.toString(), inline: true },
{ name: `:flag_${playerRegion.toLowerCase()}:`, value: ladderRegion.position.toString(), inline: true }
)
Expand Down
4 changes: 2 additions & 2 deletions functions/dateStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const CustomTypeFunc = require('../functions/customType')
const { getPagination, getMaxPage, getPageSlice } = require('./pagination')
const { getStats } = require('./apiHandler')
const { getTranslation } = require('../languages/setup')
const { generateOption, setOptionDefault, getInteractionOption } = require('./utility')
const { generateOption, setOptionDefault, getInteractionOption, getCurrentEloString } = require('./utility')

const getDates = async (playerHistory, getDay) => {
const dates = new Map()
Expand Down Expand Up @@ -93,7 +93,7 @@ const getCardWithInfo = async ({
.addFields(...head,
{ name: 'Highest Elo', value: playerLastStats['Highest Elo'].toString(), inline: true },
{ name: 'Lowest Elo', value: playerLastStats['Lowest Elo'].toString(), inline: true },
{ name: 'Current Elo', value: playerLastStats['Current Elo'].toString(), inline: true },
{ name: 'Current Elo', value: getCurrentEloString(playerLastStats), inline: true },
{ name: 'Games', value: `${playerLastStats.games} (${playerLastStats.winrate.toFixed(2)}% Win)`, inline: true },
{
name: 'Elo Gain',
Expand Down
7 changes: 6 additions & 1 deletion functions/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ const getGameOption = (interaction) => {
return interaction.options?._hoistedOptions?.filter(o => o.name === 'game')[0]?.value ?? defaultGame
}

const getCurrentEloString = (playerLastStats) => {
return `${playerLastStats['Current Elo']} (-${playerLastStats.eloToPrev}/+${playerLastStats.eloToNext})`
}

module.exports = {
generateOption,
updateDefaultOption,
setOptionDefault,
isInteractionSubcommandEqual,
getInteractionOption,
getGameOption
getGameOption,
getCurrentEloString
}

0 comments on commit 4d75587

Please sign in to comment.