Add page selection to requests
This commit is contained in:
parent
2d81f3fa11
commit
c1759f7d81
@ -459,7 +459,7 @@ const functions = {
|
||||
},
|
||||
download: {
|
||||
requests(client) {
|
||||
const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id DESC LIMIT 10';
|
||||
const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id DESC';
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.collections.requests(rows, client);
|
||||
|
@ -5,8 +5,14 @@ const fn = require('../functions.js');
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('requests')
|
||||
.setDescription('Get a list of Active requests from the database'),
|
||||
.setDescription('Get a list of Active requests from the database')
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('page')
|
||||
.setDescription('Page Number')
|
||||
.setRequired(true)),
|
||||
async execute(interaction) {
|
||||
const pageNum = interaction.options.getString('page');
|
||||
const commandData = {
|
||||
author: interaction.user.tag,
|
||||
command: interaction.commandName,
|
||||
@ -19,13 +25,15 @@ module.exports = {
|
||||
request: e.request,
|
||||
};
|
||||
});
|
||||
for (const row of requestsMap) {
|
||||
for (let i = ( 10 * ( pageNum - 1 ) ); i < ( 10 * pageNum ); i++) {
|
||||
if (requestsMap[i] != undefined) {
|
||||
commandData.requests.push({
|
||||
id: row.id,
|
||||
author: row.author,
|
||||
request: row.request,
|
||||
id: requestsMap[i].id,
|
||||
author: requestsMap[i].author,
|
||||
request: requestsMap[i].request,
|
||||
});
|
||||
}
|
||||
}
|
||||
interaction.reply(fn.embeds.requests(commandData));
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue
Block a user