From a336e21a90e645f8f1459a7e992d8d923c73262c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 18 Dec 2022 00:11:42 -0600 Subject: [PATCH] Allow choosing help page --- commands/help.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/commands/help.js b/commands/help.js index e97e471..764809f 100644 --- a/commands/help.js +++ b/commands/help.js @@ -19,16 +19,27 @@ if (fs.existsSync('./data/help-text.json')) { module.exports = { data: new SlashCommandBuilder() .setName('help') - .setDescription('Provides information on avalible commands'), + .setDescription('Provides information on avalible commands') + + // Allow choosing the help page to open + .addNumberOption(option => + option.setName('page') + .setDescription('Choose help page to skip to'), + ), + async execute(interaction) { - let pageNumber = 1; + let pageNumber = interaction.options.getNumber('page') ?? 1; const commandsPerPage = 5; let commandsThisPage = 0; const numberOfCommands = Object.keys(helpFile).length; const pageTotal = String(Math.ceil(numberOfCommands / commandsPerPage)); + if (pageNumber > pageTotal) { + pageNumber = 1; + } + let embedPartOne = { color: 0x0099ff, title: 'Help Text', @@ -131,7 +142,7 @@ module.exports = { } // Button code - const collector = interaction.channel.createMessageComponentCollector({ time: 30000 }); + const collector = interaction.channel.createMessageComponentCollector({ time: 60000 }); collector.on('collect', async i => {