const customEmbeds = require('../CustomModules/Embeds.js'); const InteractionStorage = require('../CustomModules/InteractionStorage.js'); const indexer = require('../CustomModules/Indexer.js'); const fn = require('../functions.js'); const requests = require('../slash-commands/requests.js'); module.exports = { baseEvent(interaction) { let iStorage; if (interaction.client.iStorage.has(interaction.message.interaction.id)) { iStorage = interaction.client.iStorage.get(interaction.message.interaction.id) } else { iStorage = new InteractionStorage(interaction.message.interaction.id, interaction); iStorage.page = 0; } if (interaction.user.id !== iStorage.userId) return; switch (interaction.component.customId) { // Any of the gifsPage Buttons case 'prevGifsPage': module.exports.gifsPage(interaction); break; case 'nextGifsPage': module.exports.gifsPage(interaction); break; case 'prevPastasPage': module.exports.pastasPage(interaction); break; case 'nextPastasPage': module.exports.pastasPage(interaction); break; case 'prevRequestsPage': module.exports.requestsPage(interaction); break; case 'nextRequestsPage': module.exports.requestsPage(interaction); break; case 'prevJointsPage': module.exports.jointsPage(interaction); break; case 'nextJointsPage': module.exports.jointsPage(interaction); break; default: return; } }, gifsPage(interaction) { const iStorage = interaction.client.iStorage.get(interaction.message.interaction.id); switch (interaction.component.customId) { case 'prevGifsPage': if (iStorage.page > 0) { iStorage.page = iStorage.page - 1; } break; case 'nextGifsPage': if (iStorage.page < interaction.client.gifs.size / 10) { iStorage.page = iStorage.page + 1; } break; default: break; } const indexedGifs = indexer(interaction.client.gifs, iStorage.page); indexedGifs.gifsString = new String(); for (const gif of indexedGifs.thisPage) { indexedGifs.gifsString += `[${gif.name}.gif](${gif.url})\n`; } interaction.update(fn.embeds.gifs({command: "/gifs", author: interaction.member.displayName}, indexedGifs)); }, pastasPage(interaction) { const iStorage = interaction.client.iStorage.get(interaction.message.interaction.id); switch (interaction.component.customId) { case 'prevPastasPage': if (iStorage.page > 0) { iStorage.page = iStorage.page - 1; } break; case 'nextPastasPage': if (iStorage.page < interaction.client.pastas.size / 10) { iStorage.page = iStorage.page + 1; } break; default: break; } const indexedPastas = indexer(interaction.client.pastas, iStorage.page); indexedPastas.pastasString = new String(); for (const pasta of indexedPastas.thisPage) { indexedPastas.pastasString += `${pasta.name}.pasta\n`; } interaction.update(fn.embeds.pastas({command: "/pastas", author: interaction.member.displayName}, indexedPastas)); }, requestsPage(interaction) { const iStorage = interaction.client.iStorage.get(interaction.message.interaction.id); switch (interaction.component.customId) { case 'prevRequestsPage': if (iStorage.page > 0) { iStorage.page = iStorage.page - 1; } break; case 'nextRequestsPage': if (iStorage.page < interaction.client.requests.size / 10) { iStorage.page = iStorage.page + 1; } break; default: break; } const indexedRequests = indexer(interaction.client.requests, iStorage.page); indexedRequests.requestsString = new String(); for (const request of indexedRequests.thisPage) { indexedRequests.requestsString += `[${request.id}]: ${request.request} (submitted by ${request.author})\n`; } interaction.update(fn.embeds.requests({command: "/requests", author: interaction.member.displayName}, indexedRequests)); }, jointsPage(interaction) { const iStorage = interaction.client.iStorage.get(interaction.message.interaction.id); switch (interaction.component.customId) { case 'prevJointsPage': if (iStorage.page > 0) { iStorage.page = iStorage.page - 1; } break; case 'nextJointsPage': if (iStorage.page < interaction.client.joints.size / 10) { iStorage.page = iStorage.page + 1; } break; default: break; } const indexedJoints = indexer(interaction.client.joints, iStorage.page); indexedJoints.jointsString = new String(); for (const joint of indexedJoints.thisPage) { indexedJoints.jointsString += `${joint.content}\n`; } interaction.update(fn.embeds.joints({command: "/joints", author: interaction.member.displayName}, indexedJoints)); } }