Git Product home page Git Product logo

discordjs-button-pagination's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

discordjs-button-pagination's Issues

msg branch uses deprecated way of setting footer

at line 30,56,69:

const curPage = await msg.channel.send({
    embeds: [pages[page].setFooter(`Page ${page + 1} / ${pages.length}`)],
    components: [row],
  });

should be something like this:

const curPage = await msg.channel.send({
    embeds: [pages[page].setFooter({text:`Page ${page + 1} / ${pages.length}`})],
    components: [row],
  });

Non-Embed Message Support?

Is there any plan to add a non-embed message support? I would like to only use image without the embed border.

Suggestion

Would love to see a home button on this package for the larger pages and embeds

DiscordAPIError: Unknown interaction

Im having this issue whenever i click on a button, it just says

DiscordAPIError: Unknown interaction
at RequestHandler.execute (C:\Users\Stephen\Desktop\Podz v2\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\Stephen\Desktop\Podz v2\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async ButtonInteraction.deferUpdate (C:\Users\Stephen\Desktop\Podz v2\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:183:5)
at async InteractionCollector. (C:\Users\Stephen\Desktop\Podz v2\node_modules\discordjs-button-pagination\index.js:54:5) {
method: 'post',
path: '/interactions/879587321446539344/aW50ZXJhY3Rpb246ODc5NTg3MzIxNDQ2NTM5MzQ0OnRPbWdMTzcxM0M3T3kyVEtDTWpMUGVab1JnSXpDSnl6bmdrV3Y1NVBlSnZPek9COFBRRkhKNTE3WVhRdWtNZGZUYnNMNk5qS3dJVlVZWnF2NDduQzc1VHpja0lGV3JRY0drNmR4eXFtUlBORUI4RG5kMEJCR3VwMGRVWTNTcUdJ/callback',
code: 10062,
httpStatus: 404,
requestData: { json: { type: 6 }, files: [] }
}

Unknown interaction

Everything works fine... the bot sends the message with buttons but whenever I click next or previous it doesn't goes to the next embed (though it the buttons also don't show that the interaction failed) plus there's an error in the terminal: DiscordAPIError: Unknown interaction
I don't know what's happening I have installed it by: npm i discordjs-button-pagination@msg

Button disabling timeout

How can i set the timeout for the button? I am not sure where it is but after 2 mins of inactivity the buttons get disabled, but i want it get disabled in 20-30 seconds of inactivity. How can i do it?

TypeError: Cannot read properties of undefined (reading 'deferred')

/home/runner/TESTBOT2/node_modules/discordjs-button-pagination/index.js:30
if (interaction.deferred == false){
^

TypeError: Cannot read properties of undefined (reading 'deferred')
at paginationEmbed (/home/runner/TESTBOT2/node_modules/discordjs-button-pagination/index.js:30:19)
at Command.callback [as _callback] (/home/runner/TESTBOT2/commands/inventory.js:46:1)
at Command.execute (/home/runner/TESTBOT2/node_modules/wokcommands/dist/Command.js:79:34)
at Client. (/home/runner/TESTBOT2/node_modules/wokcommands/dist/CommandHandler.js:126:29)

it sends this error how do i fix this? 
  `const paginationEmbed = require('discordjs-button-pagination');

// Use MessageEmbed to make pages
// Keep in mind that Embeds should't have their footers set since the pagination method sets page info there
const { MessageEmbed , MessageButton} = require('discord.js');

module.exports = {
name: "inv",
description: "test",
category: "n",
callback: async ({interaction, message, user}) => {
const embed1 = new MessageEmbed()
               .setTitle('First Page')
               .setDescription('This is the first page');

const embed2 = new MessageEmbed()
               .setTitle('Second Page')
               .setDescription('This is the second page');

const button1 = new MessageButton()
               .setCustomId('previousbtn')
               .setLabel('Previous')
               .setStyle('DANGER');

const button2 = new MessageButton()
               .setCustomId('nextbtn')
               .setLabel('Next')
               .setStyle('SUCCESS');

pages = [
   embed1,
   embed2,
];


buttonList = [
   button1,
   button2
]

timeout = "100000"

paginationEmbed(interaction, pages, buttonList, timeout);
   },
}`

here the code

.

.

Latest Merge Defers Already Deferred Replies

The change that was made to the module earlier still errors out when dealing with an interaction with a deferred reply that's passed through, since embed generation will take place before the function is called, making passing an undeferred interaction unfeasable in situations that need it. deferUpdate() might be worth a shot.

Cannot read property 'setFooter' of undefined

Hello, using the module and sometimes im receiving "Cannot read property 'setFooter' of undefined at origin "embeds: [pages[page].setFooter(Page ${page + 1} / ${pages.length})]," at line 36

Can only interact with message author

Hi, first of all, thank you for this package made my work easier. But, the only thing that bothers me is the button can interact with not the message author. If you could make this so only the message author can interact with the buttons that would be awesome.

Add ephemeral option

Hello.

First of all, thank you for making my life more simple with this package.
However, this might be due to my lacking knowledge about programming, but I wish for an option to make the embed + buttons ephemeral.

usually I would have something like:
interaction.reply({ embeds: [embed], ephemeral: true });
but I'm not sure how I'm supposed to make that work with this package.

Disabling the buttons after the timeout expires throws an Exception when the interaction is done in a channel hidden for the bot

The plugin throws an error after the timeout expires when the initial interaction is done in a channel hidden for the bot.

image

This line seems to cause the error:

https://github.com/ryzyx/discordjs-button-pagination/blob/interaction/index.js#L73

Changing it to this also seems to fix the issue:

collector.on("end", () => {
  if (!curPage.deleted) {
    const disabledRow = new MessageActionRow().addComponents(
      buttonList[0].setDisabled(true),
      buttonList[1].setDisabled(true)
    );
    // curPage.edit({ // throws an error when the channel is hidden for the bot
    interaction.editReply({ // seems to fix to issue
      embeds: [pages[page].setFooter(`Page ${page + 1} / ${pages.length}`)],
      components: [disabledRow],
    });
  }
});

Some error info:

{
    "name": "DiscordAPIError",
    "message": "Missing Access",
    "method": "patch",
    "path": "/channels/*snip*/messages/*snip*",
    "code": 50001,
    "httpStatus": 403,
    "requestData": {
        *snip*
    }
}

Page 1 / 1

I do not need to display buttons when there is only a single page.
image

interaction.reply is not a function

Hi, trying to set this up and getting 'interaction.reply is not a function` error.

const curPage = await interaction.reply({

   ^

TypeError: interaction.reply is not a function

I'm using the exact setup as the example provided, and I have the same declarations/requirements at the top as well.

DiscordJS: 13.6.0

"Error [INTERACTION_ALREADY_REPLIED]" when embed reply occurs

I noticed that every time I called "paginationEmbed()" I would receive an error stating that the Interaction has already been "sent or deferred". I dug around the code and found that commit 95a0108 in PR #35 seems to cause this.

Since line 36 guarantees that the interaction will be deferred, the next reply has to be an editReply() call and not reply(). Otherwise, the reply() call occurring right after guaranteeing the interaction is deferred will always error no matter what.

Suggestion

Instead of looping through the embeds when you reach the end, the button(s) would be disabled.

For example, on the first page the "Previous" button would be disabled.

(Easy to implement, but definitely could help new users.)

Add Support For Deferred Replies

Not all embed generation can be done within 3 seconds, especially for more complex uses such as leaderboards or anything that touches a database. For these cases, deferred replies should also be supported in order to expand the usefulness of the module.

Allow custom footers

Currently the code here overwrites footers. The ability to disable this would be fantastic. In my case "Result" works better and I'm fine calculating index and total page count myself.

ERROR pages[page].setFooter is not a function

hey i have a error with ur module :
error :
TypeError: pages[page].setFooter is not a function
at paginationEmbed (C:\Users\Mauri\Desktop\Bot\tsu_v13\node_modules\discordjs-button-pagination\index.js:40:26)
image_2022-04-19_012825170

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.