Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Update util.js #134

Merged
merged 1 commit into from
Aug 23, 2021
Merged

Update util.js #134

merged 1 commit into from
Aug 23, 2021

Conversation

rajamoulimallareddy
Copy link
Contributor

No description provided.

@Allvaa
Copy link
Owner

Allvaa commented Aug 21, 2021

is there any reason to put the if statement in there?

@rajamoulimallareddy
Copy link
Contributor Author

rajamoulimallareddy commented Aug 21, 2021

is there any reason to put the if statement in there?

yes cause I tried removing it and clicked on a button it just disables the button only after a single click

@yofukashino
Copy link
Contributor

Well you can disable that single click issue by removing max from collector itself also

@rajamoulimallareddy
Copy link
Contributor Author

Well you can disable that single click issue by removing max from collector itself also

tried but still the same

@yofukashino
Copy link
Contributor

yofukashino commented Aug 22, 2021

well this is ```
static get paginationEmojis() {
return ["⏮", "◀", "⛔", "▶", "⏭"];
}

static async pagination(msg, author, contents, currPage = 0) {
    /** @type {import("discord.js").InteractionCollector} */
    const collector = msg.createMessageComponentCollector({
        filter: interaction => this.paginationEmojis.includes(interaction.customId) && interaction.user.id === author.id,
        componentType: "BUTTON",
        time: 30000
    });

    collector
        .on("collect", async (interaction) => {
            await interaction.deferUpdate();
            const emoji = interaction.customId;
            if (emoji === this.paginationEmojis[0]) (currPage = 0);
            if (emoji === this.paginationEmojis[1]) currPage--;
            if (emoji === this.paginationEmojis[2]) {
                await interaction.editReply({ components: [new MessageActionRow().addComponents(...interaction.message.components[0].components.map(x => x.setDisabled(true)))] });
                return;
            }
            if (emoji === this.paginationEmojis[3]) currPage++;
            if (emoji === this.paginationEmojis[4]) (currPage = (contents.length - 1));
            currPage = ((currPage % contents.length) + contents.length) % contents.length;
            const embed = interaction.message.embeds[0]
                .setDescription(contents[currPage])
                .setFooter(`Page ${currPage + 1} of ${contents.length}.`);
            await interaction.editReply({ embeds: [embed] });
            this.pagination(msg, author, contents, currPage);
        } 
        )
        .on("end", () => {
            msg.edit({ components: [new MessageActionRow().addComponents(...msg.components[0].components.map(x => x.setDisabled(true)))] });
        });
}
    Working Fine for me

@Allvaa Allvaa merged commit 2083628 into Allvaa:djs13 Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants