Unable to import a component from a file to another

Hi, i'm trying to get a select menu exported in a file in order to use it in another one by importing it but i get this error (i tried with buttons and i got the same thing): When the function is in the same file i don't get the issue
TypeError: (0 , modulesMenu_1.buildSelectMenu) is not a function
at Object.execute (\bot\dist\modules\setup\commands\module.js:52:68)
at handleCommandInteraction (\bot\dist\modules\core\events\client\interactionCreate.js:36:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (\bot\dist\modules\core\events\client\interactionCreate.js:17:13)
TypeError: (0 , modulesMenu_1.buildSelectMenu) is not a function
at Object.execute (\bot\dist\modules\setup\commands\module.js:52:68)
at handleCommandInteraction (\bot\dist\modules\core\events\client\interactionCreate.js:36:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (\bot\dist\modules\core\events\client\interactionCreate.js:17:13)
The func is :
export const buildSelectMenu = (guildSettings: IGuild) => {
const selectMenu = new StringSelectMenuBuilder()
.setCustomId("modulesMenu")
.setPlaceholder(value)
.addOptions(/*options*/);

const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu);
return row;
};
export const buildSelectMenu = (guildSettings: IGuild) => {
const selectMenu = new StringSelectMenuBuilder()
.setCustomId("modulesMenu")
.setPlaceholder(value)
.addOptions(/*options*/);

const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu);
return row;
};
and i call it like this with the good import:
const selectMenu = buildSelectMenu(guildSettings);
const selectMenu = buildSelectMenu(guildSettings);
When the function buildSelectMenu is in the same file, i dont get this error I'm using Typescript 5.1.6 and djs v14.11.0
8 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Adan_ea
Adan_eaOP15mo ago
I'm not entirely sure if it's an issue with the build func from djs or just something wrong in my code, sorry if it's the latter
Parogo_72
Parogo_7215mo ago
#other-js-ts for non djs related issues (or #useful-servers)
Adan_ea
Adan_eaOP15mo ago
So definitly not djs related ?
Parogo_72
Parogo_7215mo ago
exporting a function in ts doesnt seem djs to me though
Adan_ea
Adan_eaOP15mo ago
yeah i agree with you, but i get the issue with this type of export only, whenever i use a builder and export it i get the error
Parogo_72
Parogo_7215mo ago
but you arent exporting a builder, you are exporting a function (that returns a builder which is irrelevant)
Adan_ea
Adan_eaOP15mo ago
I'll move this to #other-js-ts, sorry !close
Want results from more Discord servers?
Add your server