chore: split db file into multiple files and centralized pagination

This commit is contained in:
Ahmad 2025-04-16 17:57:17 -04:00
parent 2f5c3499e7
commit be8df5f6a2
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
11 changed files with 1612 additions and 1401 deletions

View file

@ -1,9 +1,7 @@
import {
SlashCommandBuilder,
EmbedBuilder,
ButtonBuilder,
ActionRowBuilder,
ButtonStyle,
StringSelectMenuBuilder,
APIEmbed,
JSONEncodable,
@ -11,6 +9,7 @@ import {
import { getAllMembers } from '@/db/db.js';
import { Command } from '@/types/CommandTypes.js';
import { createPaginationButtons } from '@/util/helpers.js';
const command: Command = {
data: new SlashCommandBuilder()
@ -42,18 +41,7 @@ const command: Command = {
let currentPage = 0;
const getButtonActionRow = () =>
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId('previous')
.setLabel('Previous')
.setStyle(ButtonStyle.Primary)
.setDisabled(currentPage === 0),
new ButtonBuilder()
.setCustomId('next')
.setLabel('Next')
.setStyle(ButtonStyle.Primary)
.setDisabled(currentPage === pages.length - 1),
);
createPaginationButtons(pages.length, currentPage);
const getSelectMenuRow = () => {
const options = pages.map((_, index) => ({
@ -85,7 +73,7 @@ const command: Command = {
if (pages.length <= 1) return;
const collector = message.createMessageComponentCollector({
time: 60000,
time: 300000,
});
collector.on('collect', async (i) => {
@ -98,10 +86,19 @@ const command: Command = {
}
if (i.isButton()) {
if (i.customId === 'previous' && currentPage > 0) {
currentPage--;
} else if (i.customId === 'next' && currentPage < pages.length - 1) {
currentPage++;
switch (i.customId) {
case 'first':
currentPage = 0;
break;
case 'prev':
if (currentPage > 0) currentPage--;
break;
case 'next':
if (currentPage < pages.length - 1) currentPage++;
break;
case 'last':
currentPage = pages.length - 1;
break;
}
}