Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discord.js v14 compatibility #15

Open
psibean opened this issue Sep 13, 2022 · 5 comments
Open

discord.js v14 compatibility #15

psibean opened this issue Sep 13, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@psibean
Copy link
Owner

psibean commented Sep 13, 2022

Currently in progress: https://github.com/psibean/discord.js-pagination/tree/feature/update-discordjs-v14

Example app is partially working, just some bugs with the select menu options, however using SelectMenuOptionsBuilder#from doesn't seem to help as implied by the errors when using /advanced-pagination

@psibean psibean added the enhancement New feature or request label Sep 13, 2022
@psibean psibean self-assigned this Sep 13, 2022
@TheOfficialDroid
Copy link

Any updates for v14 support?

Thanks for the great work ❤

@psibean
Copy link
Owner Author

psibean commented Dec 20, 2022

Any updates for v14 support?

Thanks for the great work ❤

Unfortunately no progress here since, I suspect it still has the same problems and I haven't had the chance to dig into it. I'm happy for anyone else to dive in and give it a shot. The idea is to update discord.js to the latest for both the dev dependency, and for the example app, then test the example app and ensure they all work. Currently only one of them works, and last time I was trying, it seemed like there were some funky issues with the discordjs structures not automatically converting to / from their concrete class structures on a nested level, so it got kinda confusing.

Results may differ with the latest v14 minor/patch version

@TheOfficialDroid
Copy link

TheOfficialDroid commented Dec 20, 2022

Any updates for v14 support?
Thanks for the great work ❤

Unfortunately no progress here since, I suspect it still has the same problems and I haven't had the chance to dig into it. I'm > happy for anyone else to dive in and give it a shot. The idea is to update discord.js to the latest for both the dev dependency, and for the example app, then test the example app and ensure they all work. Currently only one of them works, and last time I was trying, it seemed like there were some funky issues with the discordjs structures not automatically converting to / from their concrete class structures on a nested level, so it got kinda confusing.

Results may differ with the latest v14 minor/patch version

I'll make a fork and dig into it; But sending paginators regardless of which from the example app always seems to result in an error relating to the description field being empty; But looping through the array and sending them as Embed works absolutely fine.

Edit: Whilst looking into the specific error I was receiving, I stumbled upon a reddit thread, where a user was keying Embed and using ... to spread, which seems to be what was causing the issue; Instead they used "toJSON" and sent the embed that way; rather than in the object form.

@psibean
Copy link
Owner Author

psibean commented Dec 21, 2022

I'll make a fork and dig into it; But sending paginators regardless of which from the example app always seems to result in an error relating to the description field being empty; But looping through the array and sending them as Embed works absolutely fine.

Yep, the description / structure of the messageOptions being sent is invalid. But in this case, it seems to be an internal problem with djs. For example, if you use straight up JSON data, but then some of the children are discordjs builders instead, they don't get evaluated to their json equivalents, and thus they end up as invalid.

For the component paginators, I believe this has something to do with the getMessageOptions and the get component parts returning a mix of json and djs builders. I didn't get that far into it.

@TheOfficialDroid
Copy link

TheOfficialDroid commented Dec 21, 2022

Yep, the description / structure of the messageOptions being sent is invalid. But in this case, it seems to be an internal problem with djs. For example, if you use straight up JSON data, but then some of the children are discordjs builders instead, they don't get evaluated to their json equivalents, and thus they end up as invalid.

For the component paginators, I believe this has something to do with the getMessageOptions and the get component parts returning a mix of json and djs builders. I didn't get that far into it.

I'm yet to do further testing for alternative Pagination reply types; However changing the following to the following snipper (after); Seems to have resolved the error being returned entirely, I'll need to test the other paginators, but for all intensive purposes, the button paginator works.

if (this.useCache && options.pages && options.pages.length > 0) {
      const { pages } = options;
      pages.forEach((page, pageIndex) => {
        this.pages.set(pageIndex, page);
      });
    }
    if (this.useCache && options.pages && options.pages.length > 0) {
      const { pages } = options;
      pages.forEach((page, pageIndex) => {
        this.pages.set(pageIndex, page.toJSON());
      });
    }

Ultimately, it might come down to a case of type checking the page options as they're added in the loop and JSON'ifying embedbuilders, which /should/ at least provide a temporary fix until djs resolves the issue on their side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants