use centralized dictionary instead of hardcoded if-else for each game
This commit is contained in:
@ -1,14 +1,11 @@
|
||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const noblox = require("noblox.js");
|
||||
const { bhopCookie, surfCookie, deathrunCookie } = require("../config/config.json");
|
||||
const { cookies, commands } = require("../config/config.js");
|
||||
|
||||
async function execute(interaction) {
|
||||
const game = interaction.options.getString("game");
|
||||
let cookie;
|
||||
if (game === "bhop") cookie = bhopCookie;
|
||||
else if (game === "surf") cookie = surfCookie;
|
||||
else if (game === "deathrun") cookie = deathrunCookie;
|
||||
else {
|
||||
const cookie = cookies[game];
|
||||
if (cookie === undefined) {
|
||||
await interaction.reply({content: "Invalid game specified!", ephemeral: true});
|
||||
return;
|
||||
}
|
||||
@ -59,7 +56,7 @@ module.exports = {
|
||||
option.setName("game")
|
||||
.setDescription("Select the maptest game")
|
||||
.setRequired(true)
|
||||
.addChoices({name: "bhop", value: "bhop"}, {name: "surf", value: "surf"}, {name: "deathrun", value: "deathrun"}))
|
||||
.addChoices(commands))
|
||||
.addIntegerOption(option =>
|
||||
option.setName("asset_id")
|
||||
.setDescription("The asset ID of the model")
|
||||
@ -151,4 +148,4 @@ function getProductInfo (asset) {
|
||||
return reject(error);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user