From dd8fc46bd19993c0cd1437cfe9b8a526dcc3394c Mon Sep 17 00:00:00 2001 From: mezotv Date: Fri, 8 Sep 2023 01:26:44 +0000 Subject: [PATCH] chore(style): format files --- src/buttons/neverhaveiever.js | 5 +- src/buttons/paginateFirst.js | 87 +++++++++++--------- src/buttons/paginateLast.js | 87 +++++++++++--------- src/buttons/paginateNext.js | 143 ++++++++++++++++++--------------- src/buttons/paginatePrev.js | 143 ++++++++++++++++++--------------- src/buttons/welcomeTest.js | 10 ++- src/buttons/wouldyourather.js | 5 +- src/commands/custom.js | 29 +++++-- src/commands/neverhaveiever.js | 5 +- src/commands/wouldyourather.js | 5 +- src/events/guildCreate.js | 9 ++- src/events/guildDelete.js | 9 ++- src/events/guildMemberAdd.js | 10 ++- src/util/pagination.js | 111 ++++++++++++++----------- src/util/wouldYou.js | 2 +- 15 files changed, 366 insertions(+), 294 deletions(-) diff --git a/src/buttons/neverhaveiever.js b/src/buttons/neverhaveiever.js index c7ce0d20..08960362 100644 --- a/src/buttons/neverhaveiever.js +++ b/src/buttons/neverhaveiever.js @@ -22,8 +22,9 @@ module.exports = { "You don't have permission to use this button in this channel!", ephemeral: true, }); - const { Funny, Basic, Young, Food, RuleBreak } = - await require(`../data/nhie-${guildDb.language}.json`); + const { Funny, Basic, Young, Food, RuleBreak } = await require( + `../data/nhie-${guildDb.language}.json`, + ); const dbquestions = guildDb.customMessages.filter( (c) => c.type !== "nsfw" && c.type === "neverhaveiever", ); diff --git a/src/buttons/paginateFirst.js b/src/buttons/paginateFirst.js index dd647665..619936b3 100644 --- a/src/buttons/paginateFirst.js +++ b/src/buttons/paginateFirst.js @@ -1,46 +1,53 @@ const { ButtonBuilder, ActionRowBuilder, EmbedBuilder } = require("discord.js"); module.exports = { - data: { - name: "paginateFirst", - description: "Pagination first", - }, - async execute(interaction, client, guildDb) { - const paginate = client.paginate.get(interaction.user.id); - if (!paginate) return interaction.reply({ content: client.translation.get(guildDb?.language, "wyCustom.error.issue"), ephemeral: true }) + data: { + name: "paginateFirst", + description: "Pagination first", + }, + async execute(interaction, client, guildDb) { + const paginate = client.paginate.get(interaction.user.id); + if (!paginate) + return interaction.reply({ + content: client.translation.get( + guildDb?.language, + "wyCustom.error.issue", + ), + ephemeral: true, + }); - const buttons = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginateFirst") - .setLabel("⏪") - .setStyle("Secondary"), - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginatePrev") - .setLabel("◀️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateNext") - .setLabel("▶️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateLast") - .setLabel("⏩") - .setStyle("Secondary"), - ); + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginateFirst") + .setLabel("⏪") + .setStyle("Secondary"), + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginatePrev") + .setLabel("◀️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateNext") + .setLabel("▶️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateLast") + .setLabel("⏩") + .setStyle("Secondary"), + ); + await interaction.update({ + embeds: [paginate.pages[0]], + components: [buttons], + ephemeral: true, + }); - await interaction.update({ - embeds: [paginate.pages[0]], - components: [buttons], - ephemeral: true, - }); + clearTimeout(paginate.timeout); + const time = setTimeout(() => { + if (client.paginate.get(this.user)) client.paginate.delete(this.user); + }, paginate.time); + paginate.timeout = time; - clearTimeout(paginate.timeout); - const time = setTimeout(() => { if (client.paginate.get(this.user)) client.paginate.delete(this.user); }, paginate.time); - paginate.timeout = time; - - return (paginate.page = 0); - } -} \ No newline at end of file + return (paginate.page = 0); + }, +}; diff --git a/src/buttons/paginateLast.js b/src/buttons/paginateLast.js index 032cb820..29833e71 100644 --- a/src/buttons/paginateLast.js +++ b/src/buttons/paginateLast.js @@ -1,46 +1,53 @@ const { ButtonBuilder, ActionRowBuilder, EmbedBuilder } = require("discord.js"); module.exports = { - data: { - name: "paginateLast", - description: "Paginate last", - }, - async execute(interaction, client, guildDb) { - const paginate = client.paginate.get(interaction.user.id); - if (!paginate) return interaction.reply({ content: client.translation.get(guildDb?.language, "wyCustom.error.issue"), ephemeral: true }) + data: { + name: "paginateLast", + description: "Paginate last", + }, + async execute(interaction, client, guildDb) { + const paginate = client.paginate.get(interaction.user.id); + if (!paginate) + return interaction.reply({ + content: client.translation.get( + guildDb?.language, + "wyCustom.error.issue", + ), + ephemeral: true, + }); - const buttons = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId("paginateFirst") - .setLabel("⏪") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginatePrev") - .setLabel("◀️") - .setStyle("Secondary"), - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginateNext") - .setLabel("▶️") - .setStyle("Secondary"), - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginateLast") - .setLabel("⏩") - .setStyle("Secondary"), - ); + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("paginateFirst") + .setLabel("⏪") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginatePrev") + .setLabel("◀️") + .setStyle("Secondary"), + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginateNext") + .setLabel("▶️") + .setStyle("Secondary"), + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginateLast") + .setLabel("⏩") + .setStyle("Secondary"), + ); + await interaction.update({ + embeds: [paginate.pages[paginate.pages.length - 1]], + components: [buttons], + ephemeral: true, + }); - await interaction.update({ - embeds: [paginate.pages[paginate.pages.length - 1]], - components: [buttons], - ephemeral: true, - }); + clearTimeout(paginate.timeout); + const time = setTimeout(() => { + if (client.paginate.get(this.user)) client.paginate.delete(this.user); + }, paginate.time); + paginate.timeout = time; - clearTimeout(paginate.timeout); - const time = setTimeout(() => { if (client.paginate.get(this.user)) client.paginate.delete(this.user); }, paginate.time); - paginate.timeout = time; - - return (paginate.page = paginate.pages.length - 1); - } -} \ No newline at end of file + return (paginate.page = paginate.pages.length - 1); + }, +}; diff --git a/src/buttons/paginateNext.js b/src/buttons/paginateNext.js index 855292d6..22d6f29b 100644 --- a/src/buttons/paginateNext.js +++ b/src/buttons/paginateNext.js @@ -1,75 +1,84 @@ const { ButtonBuilder, ActionRowBuilder, EmbedBuilder } = require("discord.js"); module.exports = { - data: { - name: "paginateNext", - description: "Paginate next", - }, - async execute(interaction, client, guildDb) { - const paginate = client.paginate.get(interaction.user.id); - if (!paginate) return interaction.reply({ content: client.translation.get(guildDb?.language, "wyCustom.error.issue"), ephemeral: true }) + data: { + name: "paginateNext", + description: "Paginate next", + }, + async execute(interaction, client, guildDb) { + const paginate = client.paginate.get(interaction.user.id); + if (!paginate) + return interaction.reply({ + content: client.translation.get( + guildDb?.language, + "wyCustom.error.issue", + ), + ephemeral: true, + }); - if ((paginate.page + 1) === (paginate.pages.length - 1)) { - const buttons = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId("paginateFirst") - .setLabel("⏪") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginatePrev") - .setLabel("◀️") - .setStyle("Secondary"), - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginateNext") - .setLabel("▶️") - .setStyle("Secondary"), - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginateLast") - .setLabel("⏩") - .setStyle("Secondary"), - ); + if (paginate.page + 1 === paginate.pages.length - 1) { + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("paginateFirst") + .setLabel("⏪") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginatePrev") + .setLabel("◀️") + .setStyle("Secondary"), + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginateNext") + .setLabel("▶️") + .setStyle("Secondary"), + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginateLast") + .setLabel("⏩") + .setStyle("Secondary"), + ); - clearTimeout(paginate.timeout); - const time = setTimeout(() => { if (client.paginate.get(this.user)) client.paginate.delete(this.user); }, paginate.time); - paginate.timeout = time; + clearTimeout(paginate.timeout); + const time = setTimeout(() => { + if (client.paginate.get(this.user)) client.paginate.delete(this.user); + }, paginate.time); + paginate.timeout = time; - return await interaction.update({ - embeds: [paginate.pages[++paginate.page]], - components: [buttons], - ephemeral: true, - }); - } else { - const buttons = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId("paginateFirst") - .setLabel("⏪") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginatePrev") - .setLabel("◀️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateNext") - .setLabel("▶️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateLast") - .setLabel("⏩") - .setStyle("Secondary"), - ); + return await interaction.update({ + embeds: [paginate.pages[++paginate.page]], + components: [buttons], + ephemeral: true, + }); + } else { + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("paginateFirst") + .setLabel("⏪") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginatePrev") + .setLabel("◀️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateNext") + .setLabel("▶️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateLast") + .setLabel("⏩") + .setStyle("Secondary"), + ); - clearTimeout(paginate.timeout); - const time = setTimeout(() => { if (client.paginate.get(this.user)) client.paginate.delete(this.user); }, paginate.time); - paginate.timeout = time; + clearTimeout(paginate.timeout); + const time = setTimeout(() => { + if (client.paginate.get(this.user)) client.paginate.delete(this.user); + }, paginate.time); + paginate.timeout = time; - return await interaction.update({ - embeds: [paginate.pages[++paginate.page]], - components: [buttons], - ephemeral: true, - }); - } + return await interaction.update({ + embeds: [paginate.pages[++paginate.page]], + components: [buttons], + ephemeral: true, + }); } -} \ No newline at end of file + }, +}; diff --git a/src/buttons/paginatePrev.js b/src/buttons/paginatePrev.js index 15c8962a..b43d4669 100644 --- a/src/buttons/paginatePrev.js +++ b/src/buttons/paginatePrev.js @@ -1,75 +1,84 @@ const { ButtonBuilder, ActionRowBuilder, EmbedBuilder } = require("discord.js"); module.exports = { - data: { - name: "paginatePrev", - description: "Paginate Prev", - }, - async execute(interaction, client, guildDb) { - const paginate = client.paginate.get(interaction.user.id); - if (!paginate) return interaction.reply({ content: client.translation.get(guildDb?.language, "wyCustom.error.issue"), ephemeral: true }) + data: { + name: "paginatePrev", + description: "Paginate Prev", + }, + async execute(interaction, client, guildDb) { + const paginate = client.paginate.get(interaction.user.id); + if (!paginate) + return interaction.reply({ + content: client.translation.get( + guildDb?.language, + "wyCustom.error.issue", + ), + ephemeral: true, + }); - if (paginate.page - 1 === 0) { - const buttons = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginateFirst") - .setLabel("⏪") - .setStyle("Secondary"), - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginatePrev") - .setLabel("◀️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateNext") - .setLabel("▶️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateLast") - .setLabel("⏩") - .setStyle("Secondary"), - ); + if (paginate.page - 1 === 0) { + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginateFirst") + .setLabel("⏪") + .setStyle("Secondary"), + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginatePrev") + .setLabel("◀️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateNext") + .setLabel("▶️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateLast") + .setLabel("⏩") + .setStyle("Secondary"), + ); - clearTimeout(paginate.timeout); - const time = setTimeout(() => { if (client.paginate.get(this.user)) client.paginate.delete(this.user); }, paginate.time); - paginate.timeout = time; + clearTimeout(paginate.timeout); + const time = setTimeout(() => { + if (client.paginate.get(this.user)) client.paginate.delete(this.user); + }, paginate.time); + paginate.timeout = time; - return await interaction.update({ - embeds: [paginate.pages[--paginate.page]], - components: [buttons], - ephemeral: true, - }); - } else { - const buttons = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId("paginateFirst") - .setLabel("⏪") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginatePrev") - .setLabel("◀️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateNext") - .setLabel("▶️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateLast") - .setLabel("⏩") - .setStyle("Secondary"), - ); + return await interaction.update({ + embeds: [paginate.pages[--paginate.page]], + components: [buttons], + ephemeral: true, + }); + } else { + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("paginateFirst") + .setLabel("⏪") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginatePrev") + .setLabel("◀️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateNext") + .setLabel("▶️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateLast") + .setLabel("⏩") + .setStyle("Secondary"), + ); - clearTimeout(paginate.timeout); - const time = setTimeout(() => { if (client.paginate.get(this.user)) client.paginate.delete(this.user); }, paginate.time); - paginate.timeout = time; + clearTimeout(paginate.timeout); + const time = setTimeout(() => { + if (client.paginate.get(this.user)) client.paginate.delete(this.user); + }, paginate.time); + paginate.timeout = time; - return await interaction.update({ - embeds: [paginate.pages[--paginate.page]], - components: [buttons], - ephemeral: true, - }); - } + return await interaction.update({ + embeds: [paginate.pages[--paginate.page]], + components: [buttons], + ephemeral: true, + }); } -} \ No newline at end of file + }, +}; diff --git a/src/buttons/welcomeTest.js b/src/buttons/welcomeTest.js index 60e5be92..a475a29d 100644 --- a/src/buttons/welcomeTest.js +++ b/src/buttons/welcomeTest.js @@ -5,10 +5,12 @@ module.exports = { description: "Welcome Test", }, async execute(interaction, client, guildDb) { - const { General } = - await require(`../data/rather-${guildDb.language}.json`); - const { WhatYouDo } = - await require(`../data/wwyd-${guildDb.language}.json`); + const { General } = await require( + `../data/rather-${guildDb.language}.json`, + ); + const { WhatYouDo } = await require( + `../data/wwyd-${guildDb.language}.json`, + ); let randomDaily = []; if (guildDb.customTypes === "regular") { diff --git a/src/buttons/wouldyourather.js b/src/buttons/wouldyourather.js index 408c5991..79dd6cf7 100644 --- a/src/buttons/wouldyourather.js +++ b/src/buttons/wouldyourather.js @@ -23,8 +23,9 @@ module.exports = { ephemeral: true, }); - const { General } = - await require(`../data/rather-${guildDb.language}.json`); + const { General } = await require( + `../data/rather-${guildDb.language}.json`, + ); const dbquestions = guildDb.customMessages.filter( (c) => c.type !== "nsfw" && c.type === "wouldyourather", ); diff --git a/src/commands/custom.js b/src/commands/custom.js index cf308433..6c228156 100644 --- a/src/commands/custom.js +++ b/src/commands/custom.js @@ -7,7 +7,7 @@ const { } = require("discord.js"); const axios = require("axios"); const guildModel = require("../util/Models/guildModel"); -const Paginator = require("../util/pagination") +const Paginator = require("../util/pagination"); require("dotenv").config(); function makeID(length) { @@ -246,10 +246,25 @@ module.exports = { "wyCustom.error.empty", ), }); - - if (client.paginate.get(interaction.user.id)) return interaction.reply({ content: `${client.translation.get(guildDb?.language, "wyCustom.error.paginate")} [Link](https://canary.discord.com/channels/${interaction.guild.id}/${client.paginate.get(interaction.user.id).channel}/${client.paginate.get(interaction.user.id).message})`, ephemeral: true}) - const page = new Paginator({ user: interaction.user.id, timeout: 180000, client }); + if (client.paginate.get(interaction.user.id)) + return interaction.reply({ + content: `${client.translation.get( + guildDb?.language, + "wyCustom.error.paginate", + )} [Link](https://canary.discord.com/channels/${ + interaction.guild.id + }/${client.paginate.get(interaction.user.id).channel}/${ + client.paginate.get(interaction.user.id).message + })`, + ephemeral: true, + }); + + const page = new Paginator({ + user: interaction.user.id, + timeout: 180000, + client, + }); if ( guildDb.customMessages.filter( @@ -291,7 +306,7 @@ module.exports = { guildDb?.language, "wyCustom.success.paginator.descCatNHIE", )}\n\n${e.slice(0, 5).join("\n\n").toString()}`, - ) + ) .setColor("#0795F6"), ), ); @@ -337,7 +352,7 @@ module.exports = { guildDb?.language, "wyCustom.success.paginator.descCatWYR", )}\n\n${e.slice(0, 5).join("\n\n").toString()}`, - ) + ) .setColor("#0795F6"), ), ); @@ -379,7 +394,7 @@ module.exports = { guildDb?.language, "wyCustom.success.paginator.descCatWWYD", )}\n\n${e.slice(0, 5).join("\n\n").toString()}`, - ) + ) .setColor("#0795F6"), ), ); diff --git a/src/commands/neverhaveiever.js b/src/commands/neverhaveiever.js index 1dbac197..37e0a71a 100644 --- a/src/commands/neverhaveiever.js +++ b/src/commands/neverhaveiever.js @@ -27,8 +27,9 @@ module.exports = { */ async execute(interaction, client, guildDb) { - const { Funny, Basic, Young, Food, RuleBreak } = - await require(`../data/nhie-${guildDb.language}.json`); + const { Funny, Basic, Young, Food, RuleBreak } = await require( + `../data/nhie-${guildDb.language}.json`, + ); const dbquestions = guildDb.customMessages.filter( (c) => c.type !== "nsfw" && c.type === "neverhaveiever", ); diff --git a/src/commands/wouldyourather.js b/src/commands/wouldyourather.js index db9f3cbe..d4b6bae0 100644 --- a/src/commands/wouldyourather.js +++ b/src/commands/wouldyourather.js @@ -27,8 +27,9 @@ module.exports = { */ async execute(interaction, client, guildDb) { - const { General } = - await require(`../data/rather-${guildDb.language}.json`); + const { General } = await require( + `../data/rather-${guildDb.language}.json`, + ); const dbquestions = guildDb.customMessages.filter( (c) => c.type !== "nsfw" && c.type === "wouldyourather", ); diff --git a/src/events/guildCreate.js b/src/events/guildCreate.js index 7cbc78ec..ee174517 100644 --- a/src/events/guildCreate.js +++ b/src/events/guildCreate.js @@ -7,7 +7,7 @@ module.exports = async (client, guild) => { // Create and save the settings in the cache so that we don't need to do that at a command run await client.database.getGuild(guild?.id, true); - const webhookPrivate = new WebhookClient({ url: process.env.LOG_PRIVATE }); + const webhookPrivate = new WebhookClient({ url: process.env.LOG_PRIVATE }); let features; if ( @@ -19,8 +19,9 @@ module.exports = async (client, guild) => { : `<:partner:1072265822577360982>`; } - await webhookPrivate .send({ - avatarURL: "https://cdn.discordapp.com/avatars/981649513427111957/23da96bbf1eef64855a352e0e29cdc10.webp?size=96", // Make sure to update this if you ever change the link thx <3 + await webhookPrivate.send({ + avatarURL: + "https://cdn.discordapp.com/avatars/981649513427111957/23da96bbf1eef64855a352e0e29cdc10.webp?size=96", // Make sure to update this if you ever change the link thx <3 username: global?.devBot ? "Dev Bot" : "Main Bot", embeds: [ new EmbedBuilder() @@ -47,7 +48,7 @@ module.exports = async (client, guild) => { }); if (!global?.devBot) { - const webhookClient = new WebhookClient({ url: process.env.LOG_GUILDS}); + const webhookClient = new WebhookClient({ url: process.env.LOG_GUILDS }); await webhookClient .send({ diff --git a/src/events/guildDelete.js b/src/events/guildDelete.js index 8851f2ca..3a9cd9cb 100644 --- a/src/events/guildDelete.js +++ b/src/events/guildDelete.js @@ -7,7 +7,7 @@ module.exports = async (client, guild) => { // Only delete the guild settings from the cache we don't want a data lose but also don't need not used data in the cache :) await client.database.deleteGuild(guild?.id, true); - const webhookPrivate = new WebhookClient({ url: process.env.LOG_PRIVATE }); + const webhookPrivate = new WebhookClient({ url: process.env.LOG_PRIVATE }); let features; if ( @@ -19,8 +19,9 @@ module.exports = async (client, guild) => { : `<:partner:1072265822577360982>`; } - await webhookPrivate .send({ - avatarURL: "https://cdn.discordapp.com/avatars/981649513427111957/23da96bbf1eef64855a352e0e29cdc10.webp?size=96", // Make sure to update this if you ever change the link thx <3 + await webhookPrivate.send({ + avatarURL: + "https://cdn.discordapp.com/avatars/981649513427111957/23da96bbf1eef64855a352e0e29cdc10.webp?size=96", // Make sure to update this if you ever change the link thx <3 username: global?.devBot ? "Dev Bot" : "Main Bot", embeds: [ new EmbedBuilder() @@ -47,7 +48,7 @@ module.exports = async (client, guild) => { }); if (!global?.devBot) { - const webhookClient = new WebhookClient({ url: process.env.LOG_GUILDS}); + const webhookClient = new WebhookClient({ url: process.env.LOG_GUILDS }); await webhookClient .send({ diff --git a/src/events/guildMemberAdd.js b/src/events/guildMemberAdd.js index 8bfa249a..aec04c45 100644 --- a/src/events/guildMemberAdd.js +++ b/src/events/guildMemberAdd.js @@ -23,10 +23,12 @@ module.exports = async (client, member) => { ]) ) return; - const { General } = - await require(`../data/rather-${guildDb.language}.json`); - const { WhatYouDo } = - await require(`../data/wwyd-${guildDb.language}.json`); + const { General } = await require( + `../data/rather-${guildDb.language}.json`, + ); + const { WhatYouDo } = await require( + `../data/wwyd-${guildDb.language}.json`, + ); let randomDaily = []; if (guildDb.customTypes === "regular") { diff --git a/src/util/pagination.js b/src/util/pagination.js index 314ffd61..da44be8d 100644 --- a/src/util/pagination.js +++ b/src/util/pagination.js @@ -1,54 +1,69 @@ -const { - ActionRowBuilder, - ButtonBuilder, -} = require("discord.js"); +const { ActionRowBuilder, ButtonBuilder } = require("discord.js"); module.exports = class Paginator { - constructor({ user, client, timeout }) { - this.pages = []; - this.client = client; - this.user = user; - this.page = 0; - this.timeout = timeout; - } + constructor({ user, client, timeout }) { + this.pages = []; + this.client = client; + this.user = user; + this.page = 0; + this.timeout = timeout; + } - add(page) { - if (page.length) { - this.pages.push(page) - return this; - } - this.pages.push(page); - return this; + add(page) { + if (page.length) { + this.pages.push(page); + return this; } + this.pages.push(page); + return this; + } - async start(interaction) { - if (!this.pages.length) return; + async start(interaction) { + if (!this.pages.length) return; - const buttons = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginateFirst") - .setLabel("⏪") - .setStyle("Secondary"), - new ButtonBuilder() - .setDisabled(true) - .setCustomId("paginatePrev") - .setLabel("◀️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateNext") - .setLabel("▶️") - .setStyle("Secondary"), - new ButtonBuilder() - .setCustomId("paginateLast") - .setLabel("⏩") - .setStyle("Secondary"), - ); + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginateFirst") + .setLabel("⏪") + .setStyle("Secondary"), + new ButtonBuilder() + .setDisabled(true) + .setCustomId("paginatePrev") + .setLabel("◀️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateNext") + .setLabel("▶️") + .setStyle("Secondary"), + new ButtonBuilder() + .setCustomId("paginateLast") + .setLabel("⏩") + .setStyle("Secondary"), + ); - this.pages.forEach((e, i = 0) => { e.data.footer = { text: `Would You | Page ${i + 1} / ${this.pages.length}`, iconURL: this.client.user.avatarURL() } }); - const message = await interaction.reply({ embeds: [this.pages[0]], components: [buttons], ephemeral: true }); - this.client.paginate.set(this.user, { pages: this.pages, page: this.page, message: message.id, channel: interaction.channel.id, timeout: null, time: this.timeout }); - const time = setTimeout(() => { if (this.client.paginate.get(this.user)) this.client.paginate.delete(this.user); }, this.timeout); - this.client.paginate.get(this.user).timeout = time; - } -} \ No newline at end of file + this.pages.forEach((e, i = 0) => { + e.data.footer = { + text: `Would You | Page ${i + 1} / ${this.pages.length}`, + iconURL: this.client.user.avatarURL(), + }; + }); + const message = await interaction.reply({ + embeds: [this.pages[0]], + components: [buttons], + ephemeral: true, + }); + this.client.paginate.set(this.user, { + pages: this.pages, + page: this.page, + message: message.id, + channel: interaction.channel.id, + timeout: null, + time: this.timeout, + }); + const time = setTimeout(() => { + if (this.client.paginate.get(this.user)) + this.client.paginate.delete(this.user); + }, this.timeout); + this.client.paginate.get(this.user).timeout = time; + } +}; diff --git a/src/util/wouldYou.js b/src/util/wouldYou.js index 1e0d18b6..8f521770 100644 --- a/src/util/wouldYou.js +++ b/src/util/wouldYou.js @@ -75,7 +75,7 @@ module.exports = class WouldYou extends Client { // It's creating a new collection for the commands. this.commands = new Collection(); - // Allows for paginating + // Allows for paginating this.paginate = new Collection(); // The cooldown handler