Compare commits

..

3 Commits

Author SHA1 Message Date
85fd5e9de9 Merge pull request 'add flytrials' (#4) from staging into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #4
Reviewed-by: fiveman1 <fiveman1@noreply@itzana.me>
2023-03-18 20:30:54 -04:00
b44dd98976 add flytrials 2023-03-08 14:23:21 -08:00
378c456b85 use centralized dictionary instead of hardcoded if-else for each game 2023-03-08 14:23:21 -08:00
6 changed files with 32 additions and 23 deletions

View File

@ -1,15 +1,13 @@
const { SlashCommandBuilder } = require('@discordjs/builders'); const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageAttachment } = require("discord.js"); const { MessageAttachment } = require("discord.js");
const fs = require('node:fs'); const fs = require('node:fs');
const { submissions, commands } = require("../config/config.js");
async function execute(interaction) { async function execute(interaction) {
const game = interaction.options.getString("game"); const game = interaction.options.getString("game");
let fname; const fname = submissions[game];
if (game === "bhop") fname = "files/bhop_submissions.csv"; if (fname === undefined) {
else if (game === "surf") fname = "files/surf_submissions.csv";
else if (game === "deathrun") fname = "files/deathrun_submissions.csv";
else {
await interaction.reply({content: "Invalid game specified!", ephemeral: true}); await interaction.reply({content: "Invalid game specified!", ephemeral: true});
return; return;
} }
@ -33,7 +31,7 @@ module.exports = {
option.setName("game") option.setName("game")
.setDescription("Select the maptest game") .setDescription("Select the maptest game")
.setRequired(true) .setRequired(true)
.addChoices({name: "bhop", value: "bhop"}, {name: "surf", value: "surf"}, {name: "deathrun", value: "deathrun"})) .addChoices(commands))
, ,
execute execute
}; };

View File

@ -3,6 +3,7 @@ const { parse } = require("csv-parse/sync");
const fs = require('node:fs'); const fs = require('node:fs');
const noblox = require("noblox.js"); const noblox = require("noblox.js");
const axios = require("axios").default; const axios = require("axios").default;
const { submissions, commands } = require("../config/config.js");
async function robloxUserFromDiscord(id) { async function robloxUserFromDiscord(id) {
if (isNaN(id)) return undefined; if (isNaN(id)) return undefined;
@ -33,11 +34,8 @@ async function execute(interaction) {
} }
const game = interaction.options.getString("game"); const game = interaction.options.getString("game");
let fname; const fname = submissions[game];
if (game === "bhop") fname = "files/bhop_submissions.csv"; if (fname === undefined) {
else if (game === "surf") fname = "files/surf_submissions.csv";
else if (game === "deathrun") fname = "files/deathrun_submissions.csv";
else {
await interaction.reply({content: "Invalid game specified!", ephemeral: true}); await interaction.reply({content: "Invalid game specified!", ephemeral: true});
return; return;
} }
@ -97,7 +95,7 @@ module.exports = {
option.setName("game") option.setName("game")
.setDescription("Select the maptest game") .setDescription("Select the maptest game")
.setRequired(true) .setRequired(true)
.addChoices({name: "bhop", value: "bhop"}, {name: "surf", value: "surf"}, {name: "deathrun", value: "deathrun"})) .addChoices(commands))
.addIntegerOption(option => .addIntegerOption(option =>
option.setName("asset_id") option.setName("asset_id")
.setDescription("The asset ID of the model") .setDescription("The asset ID of the model")

View File

@ -1,14 +1,11 @@
const { SlashCommandBuilder } = require('@discordjs/builders'); const { SlashCommandBuilder } = require('@discordjs/builders');
const noblox = require("noblox.js"); const noblox = require("noblox.js");
const { bhopCookie, surfCookie, deathrunCookie } = require("../config/config.json"); const { cookies, commands } = require("../config/config.js");
async function execute(interaction) { async function execute(interaction) {
const game = interaction.options.getString("game"); const game = interaction.options.getString("game");
let cookie; const cookie = cookies[game];
if (game === "bhop") cookie = bhopCookie; if (cookie === undefined) {
else if (game === "surf") cookie = surfCookie;
else if (game === "deathrun") cookie = deathrunCookie;
else {
await interaction.reply({content: "Invalid game specified!", ephemeral: true}); await interaction.reply({content: "Invalid game specified!", ephemeral: true});
return; return;
} }
@ -59,7 +56,7 @@ module.exports = {
option.setName("game") option.setName("game")
.setDescription("Select the maptest game") .setDescription("Select the maptest game")
.setRequired(true) .setRequired(true)
.addChoices({name: "bhop", value: "bhop"}, {name: "surf", value: "surf"}, {name: "deathrun", value: "deathrun"})) .addChoices(commands))
.addIntegerOption(option => .addIntegerOption(option =>
option.setName("asset_id") option.setName("asset_id")
.setDescription("The asset ID of the model") .setDescription("The asset ID of the model")

1
config/.gitignore vendored
View File

@ -1,3 +1,4 @@
* *
!config.js
!example_config.json !example_config.json
!.gitignore !.gitignore

14
config/config.js Normal file
View File

@ -0,0 +1,14 @@
const { bhopCookie, surfCookie, deathrunCookie, flytrialsCookie } = require("config.json");
const cookies = {
bhop: bhopCookie,
surf: surfCookie,
deathrun: deathrunCookie,
flytrials: flytrialsCookie,
};
const submissions = {};
const commands = [];
for (const game in cookies) {
submissions[game] = "files/" + game + "_submissions.csv";
commands.push({name: game, value: game});
}
export { cookies, submissions, commands };

View File

@ -3,5 +3,6 @@
"clientId": "", "clientId": "",
"bhopCookie": "", "bhopCookie": "",
"surfCookie": "", "surfCookie": "",
"deathrunCookie": "" "deathrunCookie": "",
"flytrialsCookie": ""
} }