Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

Commit

Permalink
support all identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirasaki committed Sep 1, 2022
1 parent 132fd99 commit 0c2e7fb
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/commands/dayz/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const logger = require('@mirasaki/logger');
const { stripIndents } = require('common-tags/lib');
const { fetchPlayerDetails, getCftoolsId } = require('../../modules/cftClient');
const { colorResolver, titleCase } = require('../../util');
const steamIdRegex = /^[0-9]+$/g;

// const steamIdRegex = /^[0-9]+$/g;

const { DEBUG_STAT_COMMAND_DATA } = process.env;

Expand All @@ -13,7 +14,7 @@ module.exports = {
{
type: 3, // STRING,
name: 'identifier',
description: 'The player\'s Steam64 ID or CFTools Cloud ID',
description: 'The player\'s Steam64, CFTools Cloud, BattlEye, or Bohemia Interactive ID',
required: true
}
]
Expand Down Expand Up @@ -41,7 +42,7 @@ module.exports = {
if (!data) return;

// Data is delivered as on object with ID key parameters
const stats = data[identifier];
const stats = data[data.identifier];
if (!stats) {
interaction.editReply({
content: `${client.container.emojis.error} ${interaction.member}, no data belonging to **\`${identifier}\`** was found.`
Expand Down Expand Up @@ -115,12 +116,9 @@ const tryPlayerData = async (client, interaction, identifier) => {
const { emojis } = client.container;
const { member } = interaction;

// Transform the identifier if a steam64 is provided
const isSteamId = steamIdRegex.test(identifier);
if (isSteamId) {
const cftoolsId = await getCftoolsId(identifier);
identifier = cftoolsId || identifier;
}
// Resolve identifier to cftools id
const cftoolsId = await getCftoolsId(identifier);
identifier = cftoolsId || identifier;

// fetching from API
let data;
Expand All @@ -141,7 +139,7 @@ const tryPlayerData = async (client, interaction, identifier) => {
return undefined;
}

return data;
return { ...data, identifier };
};


0 comments on commit 0c2e7fb

Please sign in to comment.