Allow choosing help page

This commit is contained in:
Michael 2022-12-18 00:11:42 -06:00
parent 01bc1a37f9
commit a336e21a90

View file

@ -19,16 +19,27 @@ if (fs.existsSync('./data/help-text.json')) {
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('help') .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) { async execute(interaction) {
let pageNumber = 1; let pageNumber = interaction.options.getNumber('page') ?? 1;
const commandsPerPage = 5; const commandsPerPage = 5;
let commandsThisPage = 0; let commandsThisPage = 0;
const numberOfCommands = Object.keys(helpFile).length; const numberOfCommands = Object.keys(helpFile).length;
const pageTotal = String(Math.ceil(numberOfCommands / commandsPerPage)); const pageTotal = String(Math.ceil(numberOfCommands / commandsPerPage));
if (pageNumber > pageTotal) {
pageNumber = 1;
}
let embedPartOne = { let embedPartOne = {
color: 0x0099ff, color: 0x0099ff,
title: 'Help Text', title: 'Help Text',
@ -131,7 +142,7 @@ module.exports = {
} }
// Button code // Button code
const collector = interaction.channel.createMessageComponentCollector({ time: 30000 }); const collector = interaction.channel.createMessageComponentCollector({ time: 60000 });
collector.on('collect', async i => { collector.on('collect', async i => {