const { SlashCommandBuilder } = require('@discordjs/builders'); const { config } = require('dotenv'); const fn = require('../functions.js'); const indexer = require('../CustomModules/Indexer.js'); module.exports = { data: new SlashCommandBuilder() .setName('requests') .setDescription('Get a list of Active requests from the database'), async execute(interaction) { if (!interaction.client.requests) { interaction.reply('For some reason I don\'t have access to the collection of requests. Sorry about that!'); return; } let iStorage = interaction.client.iStorage.get(interaction.id); let indexedRequests = indexer(interaction.client.requests, 0); indexedRequests.requestsString = new String(); iStorage.page = 0; for (const request of indexedRequests.thisPage) { indexedRequests.requestsString += `[${request.id}]: ${request.request} (submitted by ${request.author})\n`; } const commandData = { command: "/requests", author: interaction.member.displayName }; interaction.reply(fn.embeds.requests(commandData, indexedRequests)); }, };