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 #24 from Mirasaki/23-configurable-slash-command-op…
Browse files Browse the repository at this point in the history
…tions

allow configurable slash command statistic options
  • Loading branch information
Mirasaki authored Jun 7, 2022
2 parents a4ceab9 + 77f2c49 commit 43211f2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
10 changes: 10 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"statOptions": [
"OVERALL",
"KILLS",
"KILL_DEATH_RATIO",
"LONGEST_KILL",
"PLAYTIME",
"LONGEST_SHOT",
"DEATHS",
"SUICIDES"
],
"intents": [ "GUILDS" ],
"permissions": {
"ownerId": "290182686365188096",
Expand Down
24 changes: 14 additions & 10 deletions src/commands/dayz/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ const emojiMap = {
9: ':nine:'
};

// Mapping our Interaction Command API options
const { statOptions } = require('../../../config/config.json');
const activeStatisticOptions = [
{ name: 'Overall', value: 'OVERALL' },
{ name: 'Kills', value: 'KILLS' },
{ name: 'Kill Death Ratio', value: 'KILL_DEATH_RATIO' },
{ name: 'Longest Kill', value: 'LONGEST_KILL' },
{ name: 'Playtime', value: 'PLAYTIME' },
{ name: 'Longest Shot', value: 'LONGEST_SHOT' },
{ name: 'Deaths', value: 'DEATHS' },
{ name: 'Suicides', value: 'SUICIDES' }
].filter((e) => statOptions.includes(e.value));

module.exports = {
// Defining our Discord Application Command API data
// Name is generated from the file name if left undefined
Expand All @@ -49,16 +62,7 @@ module.exports = {
description: 'The type of leaderboard to display',
type: 3, // STRING
required: false,
choices: [
{ name: 'Overall', value: 'OVERALL' },
{ name: 'Kills', value: 'KILLS' },
{ name: 'Kill Death Ratio', value: 'KILL_DEATH_RATIO' },
{ name: 'Longest Kill', value: 'LONGEST_KILL' },
{ name: 'Playtime', value: 'PLAYTIME' },
{ name: 'Longest Shot', value: 'LONGEST_SHOT' },
{ name: 'Deaths', value: 'DEATHS' },
{ name: 'Suicides', value: 'SUICIDES' }
]
choices: activeStatisticOptions
}
]
},
Expand Down

0 comments on commit 43211f2

Please sign in to comment.