I'm having some difficulty creating "next page" and "previous page" buttons using discord-buttons.
What my command so far does is grab role info from an array formatted like:
{ role: 'hot rod red', color: '#fc0000' , price: 25000, roleid: '733373020491481219', id: 'red' }
Then create embeds for each of those roles. The code I have so far sends all of the roles at once with no issues, but I am trying to get them to send one at a time, and when the "next page" button is pressed, the message edits, and it goes to the next role embed in that array, all the way to the end. Since discord buttons are fairly new, there's not that much information on them yet, so any help's appreciated, thanks! (Please let me know I need to provide more code)
Buttons are basically, a kind of alternative to using reactions. For page-like systems, it works almost identically. You send a message with reactions/buttons, wait for reactions, and then edit the message.
There are a few differences:
This means that buttons are very useful for actions such as editing the message it is on, but not as much for something like toggling a role.
Each message can have 5
ActionRows, and eachActionRowcan have 5Buttons (a total of 25)Buttons have a label, style, and a custom id (or URL, if it is a 'URL-styled' button).
Since you are using
discord-buttons, you can do something like this to send the message with buttons:Then, you can wait for the interactions using either the methods or events that
discord-buttonsprovide:discord-buttonsextends functionalities of regulardiscord.jsclasses, so similar options can be used.