From b4c35b31e83e171a4cf8f41d68f87c153a1e3b1f Mon Sep 17 00:00:00 2001 From: Mirasaki Date: Wed, 25 May 2022 07:24:13 +0200 Subject: [PATCH 1/4] update embed building to accomdate blacklist --- src/commands/dayz/leaderboard.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/dayz/leaderboard.js b/src/commands/dayz/leaderboard.js index cfe5c93..cfaaa0c 100644 --- a/src/commands/dayz/leaderboard.js +++ b/src/commands/dayz/leaderboard.js @@ -108,7 +108,7 @@ module.exports = { .getLeaderboard({ order: 'ASC', statistic: mappedStat, - limit: playerLimit + limit: 100 }); } catch (err) { // Properly logging the error if it is encountered @@ -158,7 +158,7 @@ module.exports = { } // Constructing our embed onject - const lbEmbedData = buildLeaderboardEmbed(guild, res, isDefaultQuery, statToGet, mappedStat); + const lbEmbedData = buildLeaderboardEmbed(guild, res, isDefaultQuery, statToGet, mappedStat, playerLimit); // Responding to our request interaction.editReply({ @@ -168,7 +168,7 @@ module.exports = { }; // Dedicated function for building our embed data -const buildLeaderboardEmbed = (guild, res, isDefaultQuery, statToGet, mappedStat) => { +const buildLeaderboardEmbed = (guild, res, isDefaultQuery, statToGet, mappedStat, playerLimit) => { // Initializing our embed vars let description = ''; let fields = []; @@ -225,7 +225,7 @@ const buildLeaderboardEmbed = (guild, res, isDefaultQuery, statToGet, mappedStat // Returning our build embed data return { - fields, + fields: fields.slice(0, playerLimit), color: colorResolver(), author: { name: description, From 1cefd586d9ed1d64dd4fdea64715eab07bfaaa47 Mon Sep 17 00:00:00 2001 From: Mirasaki Date: Wed, 25 May 2022 07:26:33 +0200 Subject: [PATCH 2/4] re-initialize cftools-sdk cache manager --- src/modules/cftClient.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/cftClient.js b/src/modules/cftClient.js index bf215f8..288d0b5 100644 --- a/src/modules/cftClient.js +++ b/src/modules/cftClient.js @@ -9,6 +9,7 @@ const { // export our CFTools client as unnamed default module.exports = new cftSDK.CFToolsClientBuilder() + .withCache() .withServerApiId(CFTOOLS_SERVER_API_ID) .withCredentials(CFTOOLS_API_APPLICATION_ID, CFTOOLS_API_SECRET) .build(); From 6e38375e548212e5b14556551e480f3855790072 Mon Sep 17 00:00:00 2001 From: Mirasaki Date: Wed, 25 May 2022 07:30:25 +0200 Subject: [PATCH 3/4] include the actual blacklist config file --- config/blacklist.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 config/blacklist.json diff --git a/config/blacklist.json b/config/blacklist.json new file mode 100644 index 0000000..2b4c81a --- /dev/null +++ b/config/blacklist.json @@ -0,0 +1,5 @@ +[ + "6284d7a30873a63f22e34f34", + "CFTools IDs to exclude from the blacklist", + "always use commas (,) at the end of the line EXCEPT THE LAST ONE > like so" +] \ No newline at end of file From 98254964367daed85db12ccb568b6d212915acce Mon Sep 17 00:00:00 2001 From: Mirasaki Date: Wed, 25 May 2022 07:35:20 +0200 Subject: [PATCH 4/4] filter out blacklisted ids from the API response --- src/commands/dayz/leaderboard.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/commands/dayz/leaderboard.js b/src/commands/dayz/leaderboard.js index cfaaa0c..0e24fb2 100644 --- a/src/commands/dayz/leaderboard.js +++ b/src/commands/dayz/leaderboard.js @@ -4,6 +4,9 @@ const { stripIndents } = require('common-tags/lib'); const cftClient = require('../../modules/cftClient'); const { parseSnakeCaseArray, colorResolver } = require('../../util'); +// Include our blacklist file +const leaderboardBlacklist = require('../../../config/blacklist.json'); + // Destructure from our process env const { DEBUG_LEADERBOARD_API_DATA, @@ -157,8 +160,11 @@ module.exports = { return; } + // Filter out our blacklisted ids/entries + const whitelistedData = res.filter((e) => !leaderboardBlacklist.includes(e.id.id)); + // Constructing our embed onject - const lbEmbedData = buildLeaderboardEmbed(guild, res, isDefaultQuery, statToGet, mappedStat, playerLimit); + const lbEmbedData = buildLeaderboardEmbed(guild, whitelistedData, isDefaultQuery, statToGet, mappedStat, playerLimit); // Responding to our request interaction.editReply({