const { SlashCommandBuilder } = require('@discordjs/builders'); const { MessageAttachment } = require("discord.js"); const fs = require('node:fs'); const { submissions, commands } = require("../config/config.js"); async function execute(interaction) { const game = interaction.options.getString("game"); const fname = submissions[game]; if (fname === undefined) { await interaction.reply({content: "Invalid game specified!", ephemeral: true}); return; } if (!fs.existsSync(fname)) { await interaction.reply(`No submissions exist yet for ${game}.`); return; } const csv = fs.readFileSync(fname); const file = new MessageAttachment(csv, fname); await interaction.reply({files: [file]}); } module.exports = { data: new SlashCommandBuilder() .setName('submissions') .setDescription('View the submissions in .csv format') .addStringOption(option => option.setName("game") .setDescription("Select the maptest game") .setRequired(true) .addChoices(...commands)) , execute };