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

Commit

Permalink
Merge pull request #32 from Mirasaki/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Mirasaki authored Aug 31, 2022
2 parents fc30f01 + 872d648 commit a158ff6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dayz-leaderboard-bot",
"description": "A DayZ bot written in Javascript to display your leaderboard using the CFTools Cloud API.",
"version": "1.0.9",
"version": "1.0.10",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
12 changes: 10 additions & 2 deletions src/commands/dayz/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,22 @@ module.exports = {
const { options } = interaction;
const identifier = options.getString('identifier');

// Deferring our reply
await interaction.deferReply();

// Reduce cognitive complexity
// tryPlayerData replies to interaction if anything fails
const data = await tryPlayerData(client, interaction, identifier);
if (!data) return;

// Data is delivered as on object with ID key parameters
const stats = data[identifier];
if (!stats) {
interaction.editReply({
content: `${client.container.emojis.error} ${interaction.member}, no data belonging to **\`${identifier}\`** was found.`
});
return;
}

// Detailed, conditional debug logging
if (DEBUG_STAT_COMMAND_DATA === 'true') {
Expand Down Expand Up @@ -114,8 +123,7 @@ const tryPlayerData = async (client, interaction, identifier) => {
identifier = cftoolsId || identifier;
}

// Deferring our reply and fetching from API
await interaction.deferReply();
// fetching from API
let data;
try {
data = await fetchPlayerDetails(identifier);
Expand Down

0 comments on commit a158ff6

Please sign in to comment.