[Bug]: Using @discordx/pagination
ggomaeng opened this issue · comments
What happened?
I get a SyntaxError when I try to implement a basic pagination.
The error occurs from importing StringSelectMenuBuilder
from 'discord.js'
Dependencies and logs are provided below.
What I've tried
Changing GeneratePage.js
from
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, } from "discord.js";
to
import discord from 'discord.js';
const { StringSelectMenuBuilder } = discord;
seems to fix the error, but I don't think this is the right solution.
Reproduction
"dependencies": {
"@discordx/pagination": "^3.4.0",
"discord.js": "^14.6.0",
"discordx": "^11.4.0",
}
import { Pagination } from '@discordx/pagination';
...
new Pagination(interaction, []).send();
Just a simple implementation provided in the docs.
Package
@discordx/pagination
Version
Stable
Relevant log output
![image](https://user-images.githubusercontent.com/18402191/220514693-b15c0ee8-1658-4bea-a1c1-0bcfef50c8e5.png)
file:///Users/ggoma/Projects/town-discord/node_modules/@discordx/pagination/build/esm/functions/GeneratePage.js:1
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, } from "discord.js";
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'StringSelectMenuBuilder' not found. The requested module 'discord.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'discord.js';
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
Code of Conduct
- I agree to follow this project's Code of Conduct
https://discord.com/channels/874802018361950248/876369232084992010/1077821593151094855
Think we should update the peer dependency version? Providing that the version of discord.js
he is using is in some way broken.
Bumping up the discord.js
version to ^14.7.1
seems to fix the issue.