nodbot/slash-commands/requests.js

31 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2021-09-22 17:15:31 +00:00
const { SlashCommandBuilder } = require('@discordjs/builders');
const { config } = require('dotenv');
const fn = require('../functions.js');
2024-09-26 12:37:16 +00:00
const indexer = require('../CustomModules/Indexer.js');
2021-09-22 17:15:31 +00:00
module.exports = {
data: new SlashCommandBuilder()
.setName('requests')
2024-09-26 12:37:16 +00:00
.setDescription('Get a list of Active requests from the database'),
2021-09-22 17:15:31 +00:00
async execute(interaction) {
2024-09-26 12:37:16 +00:00
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`;
}
2021-09-22 17:15:31 +00:00
const commandData = {
2024-09-26 12:37:16 +00:00
command: "/requests",
author: interaction.member.displayName
2021-09-22 17:15:31 +00:00
};
2024-09-26 12:37:16 +00:00
interaction.reply(fn.embeds.requests(commandData, indexedRequests));
2021-09-22 17:15:31 +00:00
},
};