nodbot/slash-commands/requests.js

39 lines
1.0 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');
module.exports = {
data: new SlashCommandBuilder()
.setName('requests')
2023-01-08 01:57:03 +00:00
.setDescription('Get a list of Active requests from the database')
.addStringOption(option =>
option
.setName('page')
.setDescription('Page Number')
.setRequired(true)),
2021-09-22 17:15:31 +00:00
async execute(interaction) {
2023-01-08 01:57:03 +00:00
const pageNum = interaction.options.getString('page');
2021-09-22 17:15:31 +00:00
const commandData = {
author: interaction.user.tag,
command: interaction.commandName,
requests: [],
};
const requestsMap = interaction.client.requests.map(e => {
return {
id: e.id,
author: e.author,
request: e.request,
};
});
2023-01-08 01:57:03 +00:00
for (let i = ( 10 * ( pageNum - 1 ) ); i < ( 10 * pageNum ); i++) {
if (requestsMap[i] != undefined) {
commandData.requests.push({
id: requestsMap[i].id,
author: requestsMap[i].author,
request: requestsMap[i].request,
});
}
2021-09-22 17:15:31 +00:00
}
interaction.reply(fn.embeds.requests(commandData));
},
};