From 2d81f3fa11daa34bf93f78360ed766c0ac26012b Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 20:32:38 -0500 Subject: [PATCH 1/2] Versioning --- README.md | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 07c4a95..7d31f60 100644 --- a/README.md +++ b/README.md @@ -107,4 +107,5 @@ v3.0.3 - Fix broken `/requests` command v3.0.4 - Add ability to use multiple aliases v3.0.5 - Add ability to save strains v3.0.6 - Move `.strain` to `/strain` and add Autocomplete -v3.0.7 - Add `.spongebob` replies \ No newline at end of file +v3.0.7 - Add `.spongebob` replies +v3.0.8 - Add ability to open requests by pages \ No newline at end of file diff --git a/package.json b/package.json index 84c4e54..93cfb21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.7", + "version": "3.0.8", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From c1759f7d81b003c8fc3c4ee20c8ea78b09ca9dce Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 20:57:03 -0500 Subject: [PATCH 2/2] Add page selection to requests --- functions.js | 2 +- slash-commands/requests.js | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/functions.js b/functions.js index 72e9c65..025c020 100644 --- a/functions.js +++ b/functions.js @@ -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); diff --git a/slash-commands/requests.js b/slash-commands/requests.js index 75caa80..039504e 100644 --- a/slash-commands/requests.js +++ b/slash-commands/requests.js @@ -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,12 +25,14 @@ module.exports = { request: e.request, }; }); - for (const row of requestsMap) { - commandData.requests.push({ - id: row.id, - author: row.author, - request: row.request, - }); + 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, + }); + } } interaction.reply(fn.embeds.requests(commandData)); },