nodbot/slash-commands/requests.js

31 lines
781 B
JavaScript
Raw 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')
.setDescription('Get a list of Active requests from the database'),
async execute(interaction) {
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,
};
});
for (const row of requestsMap) {
commandData.requests.push({
id: row.id,
author: row.author,
request: row.request,
});
}
interaction.reply(fn.embeds.requests(commandData));
},
};