From 85980aec812a8575e6285f35fb8db1854d234f85 Mon Sep 17 00:00:00 2001 From: JustDams Date: Fri, 13 Sep 2024 18:31:20 +0000 Subject: [PATCH 1/2] feat: hide damages, adr and entries since faceit removed those from the endpoint used by the backend --- commands/last.js | 8 +++++--- functions/dateStats.js | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/commands/last.js b/commands/last.js index 239d9de..71981da 100644 --- a/commands/last.js +++ b/commands/last.js @@ -67,9 +67,11 @@ const getMatchItems = async (interaction, playerDatas, steamDatas, playerHistory { name: 'Kills', value: roundStats.i6, inline: true }, { name: 'Deaths', value: roundStats.i8, inline: true }, { name: 'Assists', value: roundStats.i7, inline: true }, - { name: 'Damages', value: roundStats?.i20 ?? 'N/A', inline: true }, - { name: 'ADR', value: roundStats?.c10 ?? 'N/A', inline: true }, - { name: 'Entries (WR)', value: entries, inline: true },) + // Removed from faceit endpoint used by the api + // { name: 'Damages', value: roundStats?.i20 ?? 'N/A', inline: true }, + // { name: 'ADR', value: roundStats?.c10 ?? 'N/A', inline: true }, + // { name: 'Entries (WR)', value: entries, inline: true }, + ) .setThumbnail(`attachment://${faceitElo}${i}.png`) .setImage(`attachment://${mapName}.jpg`) .setColor(result ? color.won : color.lost) diff --git a/functions/dateStats.js b/functions/dateStats.js index 55a2264..5e3fb59 100644 --- a/functions/dateStats.js +++ b/functions/dateStats.js @@ -245,9 +245,10 @@ const generateDateStatsFields = (playerLastStats, head) => { { name: 'Avg Kills', value: playerLastStats['Average Kills'].toFixed(2), inline: true }, { name: 'Avg Deaths', value: playerLastStats['Average Deaths'].toFixed(2), inline: true }, { name: 'Avg Assists', value: playerLastStats['Average Assists'].toFixed(2), inline: true }, - { name: 'Avg Damages', value: playerLastStats['Average Damages']?.toString() ?? 'N/A', inline: true }, - { name: 'Avg ADR', value: playerLastStats['Average ADR']?.toString() ?? 'N/A', inline: true }, - { name: 'Avg Entries (WR)', value: entries, inline: true }, + // Removed from faceit endpoint used by the api + // { name: 'Avg Damages', value: playerLastStats['Average Damages']?.toString() ?? 'N/A', inline: true }, + // { name: 'Avg ADR', value: playerLastStats['Average ADR']?.toString() ?? 'N/A', inline: true }, + // { name: 'Avg Entries (WR)', value: entries, inline: true }, { name: 'Red K/D', value: playerLastStats['Red K/D'].toString(), inline: true }, { name: 'Orange K/D', value: playerLastStats['Orange K/D'].toString(), inline: true }, { name: 'Green K/D', value: playerLastStats['Green K/D'].toString(), inline: true }, From a8a3532c01a822842352b74e3f770f5b0819d81c Mon Sep 17 00:00:00 2001 From: JustDams Date: Fri, 13 Sep 2024 19:06:08 +0000 Subject: [PATCH 2/2] feat: map option on datestats commands --- commands/dailystats.js | 16 +++++++++++----- commands/monthstats.js | 16 +++++++++++----- commands/weekstats.js | 16 +++++++++++----- commands/yearstats.js | 16 +++++++++++----- functions/dateStats.js | 9 +++++---- functions/roles.js | 1 - interactions/buttons/pageDS.js | 4 +++- scripts/check_guild.js | 2 +- scripts/register_roles.js | 2 +- 9 files changed, 54 insertions(+), 28 deletions(-) diff --git a/commands/dailystats.js b/commands/dailystats.js index 984e475..3a0eada 100644 --- a/commands/dailystats.js +++ b/commands/dailystats.js @@ -2,7 +2,8 @@ const DateStats = require('../functions/dateStats') const { getCardsConditions } = require('../functions/commands') const Options = require('../templates/options') const { getTranslations, getTranslation } = require('../languages/setup') -const { getGameOption } = require('../functions/utility') +const { getGameOption, getInteractionOption } = require('../functions/utility') +const { getMapOption } = require('../functions/map') const getDay = date => { date = new Date(date) @@ -24,8 +25,9 @@ const formatLabel = (from, to) => { return new Date(from).toDateString() } -const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, type = null, defaultOption = 0) => { +const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, type = null, defaultOption = 0, map = null) => { game ??= getGameOption(interaction) + map ??= getInteractionOption(interaction, 'map') ?? '' return DateStats.generateDatasForCard({ interaction, @@ -37,16 +39,20 @@ const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, formatLabel, selectTranslationString: 'strings.selectDate', type, - defaultOption + defaultOption, + map }) } module.exports = { name: 'dailystats', - options: Options.stats, + options: [ + ...Options.stats, + getMapOption() + ], description: getTranslation('command.dailystats.description', 'en-US'), descriptionLocalizations: getTranslations('command.dailystats.description'), - usage: Options.usage, + usage: `${Options.usage} `, example: 'steam_parameters: justdams', type: 'stats', async execute(interaction) { diff --git a/commands/monthstats.js b/commands/monthstats.js index 1b376f8..08faaf0 100644 --- a/commands/monthstats.js +++ b/commands/monthstats.js @@ -2,7 +2,8 @@ const DateStats = require('../functions/dateStats') const { getCardsConditions } = require('../functions/commands') const Options = require('../templates/options') const { getTranslations, getTranslation } = require('../languages/setup') -const { getGameOption } = require('../functions/utility') +const { getGameOption, getInteractionOption } = require('../functions/utility') +const { getMapOption } = require('../functions/map') const getFirstDay = (x) => { const a = new Date(x) @@ -25,8 +26,9 @@ const formatLabel = (from, to, locale) => { return new Date(from).toLocaleDateString('en-EN', { month: 'short', year: 'numeric' }) } -const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, type = null, defaultOption = 0) => { +const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, type = null, defaultOption = 0, map = null) => { game ??= getGameOption(interaction) + map ??= getInteractionOption(interaction, 'map') ?? '' return DateStats.generateDatasForCard({ interaction, @@ -38,16 +40,20 @@ const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, formatLabel, selectTranslationString: 'strings.selectMonth', type, - defaultOption + defaultOption, + map }) } module.exports = { name: 'monthstats', - options: Options.stats, + options: [ + ...Options.stats, + getMapOption() + ], description: getTranslation('command.monthstats.description', 'en-US'), descriptionLocalizations: getTranslations('command.monthstats.description'), - usage: Options.usage, + usage: `${Options.usage} `, type: 'stats', async execute(interaction) { return getCardsConditions({ diff --git a/commands/weekstats.js b/commands/weekstats.js index 618c3bf..cac79a1 100644 --- a/commands/weekstats.js +++ b/commands/weekstats.js @@ -2,7 +2,8 @@ const DateStats = require('../functions/dateStats') const { getCardsConditions } = require('../functions/commands') const Options = require('../templates/options') const { getTranslation, getTranslations } = require('../languages/setup') -const { getGameOption } = require('../functions/utility') +const { getGameOption, getInteractionOption } = require('../functions/utility') +const { getMapOption } = require('../functions/map') const getMonday = date => { const week = [6, 0, 1, 2, 3, 4, 5] @@ -26,8 +27,9 @@ const formatLabel = (from, to, locale) => { return [new Date(from).toDateString(), '-', new Date(new Date(to).setHours(-24)).toDateString()].join(' ') } -const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, type = null, defaultOption = 0) => { +const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, type = null, defaultOption = 0, map = null) => { game ??= getGameOption(interaction) + map ??= getInteractionOption(interaction, 'map') ?? '' return DateStats.generateDatasForCard({ interaction, @@ -39,16 +41,20 @@ const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, formatLabel, selectTranslationString: 'strings.selectWeek', type, - defaultOption + defaultOption, + map }) } module.exports = { name: 'weekstats', - options: Options.stats, + options: [ + ...Options.stats, + getMapOption() + ], description: getTranslation('command.weekstats.description', 'en-US'), descriptionLocalizations: getTranslations('command.weekstats.description'), - usage: Options.usage, + usage: `${Options.usage} `, example: 'steam_parameters: justdams', type: 'stats', async execute(interaction) { diff --git a/commands/yearstats.js b/commands/yearstats.js index dae7f8c..ca0a1d8 100644 --- a/commands/yearstats.js +++ b/commands/yearstats.js @@ -2,7 +2,8 @@ const DateStats = require('../functions/dateStats') const { getCardsConditions } = require('../functions/commands') const Options = require('../templates/options') const { getTranslation, getTranslations } = require('../languages/setup') -const { getGameOption } = require('../functions/utility') +const { getGameOption, getInteractionOption } = require('../functions/utility') +const { getMapOption } = require('../functions/map') const getYear = date => { date = new Date(date) @@ -29,8 +30,9 @@ const formatLabel = (from, to, locale) => { return `${getTranslation('strings.year', locale)} ${new Date(from).getFullYear()}` } -const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, type = null, defaultOption = 0) => { +const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, type = null, defaultOption = 0, map = null) => { game ??= getGameOption(interaction) + map ??= getInteractionOption(interaction, 'map') ?? '' return DateStats.generateDatasForCard({ interaction, @@ -42,16 +44,20 @@ const sendCardWithInfo = async (interaction, playerParam, page = 0, game = null, formatLabel, selectTranslationString: 'strings.selectYear', type, - defaultOption + defaultOption, + map }) } module.exports = { name: 'yearstats', - options: Options.stats, + options: [ + ...Options.stats, + getMapOption() + ], description: getTranslation('command.yearstats.description', 'en-US'), descriptionLocalizations: getTranslations('command.yearstats.description'), - usage: Options.usage, + usage: `${Options.usage} `, example: 'steam_parameters: justdams', type: 'stats', async execute(interaction) { diff --git a/functions/dateStats.js b/functions/dateStats.js index 5e3fb59..2ab5afa 100644 --- a/functions/dateStats.js +++ b/functions/dateStats.js @@ -79,7 +79,7 @@ const getCardWithInfo = async ({ name: 'From - To', value: [new Date(startDate).toDateString(), '\n', new Date(endDateToRealTimeStamp).toDateString()].join(' '), inline: !!map }) - else head.push({ name: 'From', value: new Date(startDate).toDateString(), inline: false }) + else head.push({ name: 'From', value: new Date(startDate).toDateString(), inline: !!map }) if (map) head.push({ name: 'Map', value: map, inline: true }, { name: '\u200b', value: '\u200b', inline: true }) const card = new Discord.EmbedBuilder() @@ -120,7 +120,8 @@ const generateDatasForCard = async ({ formatLabel, selectTranslationString, type, - defaultOption = 0 + defaultOption = 0, + map = '' }) => { type ??= CustomType.TYPES.ELO @@ -130,7 +131,8 @@ const generateDatasForCard = async ({ } = await getStats({ playerParam, matchNumber: 0, - game + game, + map }) if (!playerHistory.length) throw getTranslation('error.user.noMatches', interaction.locale, { @@ -141,7 +143,6 @@ const generateDatasForCard = async ({ const optionsValues = [] const dates = await getDates(playerHistory, functionToGetDates) const maxMatch = 0 - const map = '' dates.forEach(date => { const { diff --git a/functions/roles.js b/functions/roles.js index cd474dc..174f28d 100644 --- a/functions/roles.js +++ b/functions/roles.js @@ -81,7 +81,6 @@ const handleRoleErrors = (err, role) => { } const logRoleUpdate = (client, member, role, guildDatas, playerElo, action) => { - console.log(role) client.guilds.fetch(logGuild) .then(guild => guild.channels.fetch(logChannel)) .then(channel => channel.send({ diff --git a/interactions/buttons/pageDS.js b/interactions/buttons/pageDS.js index f3999b6..247da25 100644 --- a/interactions/buttons/pageDS.js +++ b/interactions/buttons/pageDS.js @@ -33,7 +33,9 @@ module.exports = { { param: json.playerId, faceitId: true }, json.targetPage, json.game, - json.chartType + json.chartTypen, + 0, + json.map ) } } diff --git a/scripts/check_guild.js b/scripts/check_guild.js index 2bb1736..50cd7c9 100644 --- a/scripts/check_guild.js +++ b/scripts/check_guild.js @@ -13,7 +13,7 @@ client.on('ready', async () => { const guild = await client.guilds.fetch(guildId) if (!guild) return - console.log('Guild found:', guild.name) + console.info('Guild found:', guild.name) await updateRoles(client, null, guildId) }) diff --git a/scripts/register_roles.js b/scripts/register_roles.js index afa5e6e..2dd95b3 100644 --- a/scripts/register_roles.js +++ b/scripts/register_roles.js @@ -16,7 +16,7 @@ axios.put(url, body, { Authorization: `Bot ${process.env.TOKEN}`, }, }).then((res) => { - console.log(res.data) + console.info(res.data) }).catch((err) => { console.error(err) }) \ No newline at end of file