Components v2 error

Tried a simpler builder for now:
async execute(interaction, client) {
const components = new ComponentBuilder()
.setComponents([
new ContainerBuilder()
.setComponents([
new TextDisplay("Testing")
])
.setColor(1146986)
])

await interaction.reply(components.toJSON());
},
async execute(interaction, client) {
const components = new ComponentBuilder()
.setComponents([
new ContainerBuilder()
.setComponents([
new TextDisplay("Testing")
])
.setColor(1146986)
])

await interaction.reply(components.toJSON());
},
And this is the received error:
TypeError: ContainerBuilder is not a constructor
at Object.execute (/home/container/LiveAlertsTest/Commands/Staff/newSetup.js:17:11)
at module.exports (/home/container/LiveAlertsTest/Events/interactionCreate.js:6:17)
at Client.<anonymous> (/home/container/LiveAlertsTest/index.js:72:53)
at Client.emit (node:events:507:28)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:232:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:287:31)
at WebSocketShard.<anonymous> (/home/container/node_modules/@discordjs/ws/dist/index.js:1190:51)
TypeError: ContainerBuilder is not a constructor
at Object.execute (/home/container/LiveAlertsTest/Commands/Staff/newSetup.js:17:11)
at module.exports (/home/container/LiveAlertsTest/Events/interactionCreate.js:6:17)
at Client.<anonymous> (/home/container/LiveAlertsTest/index.js:72:53)
at Client.emit (node:events:507:28)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:232:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:287:31)
at WebSocketShard.<anonymous> (/home/container/node_modules/@discordjs/ws/dist/index.js:1190:51)
(no 14.19 tag here yet)
10 Replies
d.js toolkit
d.js toolkit3d 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!
DanielBA
DanielBAOP3d ago
Currently tried to connect using an ssh
d.js docs
d.js docs3d ago
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
DanielBA
DanielBAOP3d ago
This is the entire file
const { SeparatorSpacingSize, TextDisplayBuilder, RoleSelectBuilder, ChannelSelectBuilder, Seperator, ButtonStyle, ButtonBuilder, ComponentBuilder, TextDisplay, ContainerBuilder, Client, GatewayIntentBits, ActivityType, EmbedBuilder, SlashCommandBuilder, Routes, NewsChannel, ChannelType, PermissionFlagsBits, PermissionsBitField, Embed, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, OverwriteType } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("newsetup")
.setDMPermission(false)
.setDescription("פקודת סטאפ חדשה")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction, client) {

const components = new ComponentBuilder()
.setComponents([
new ContainerBuilder()
.setComponents([
new TextDisplay("Testing")
])
.setColor(1146986)
])


await interaction.reply(components.toJSON());
},
};
const { SeparatorSpacingSize, TextDisplayBuilder, RoleSelectBuilder, ChannelSelectBuilder, Seperator, ButtonStyle, ButtonBuilder, ComponentBuilder, TextDisplay, ContainerBuilder, Client, GatewayIntentBits, ActivityType, EmbedBuilder, SlashCommandBuilder, Routes, NewsChannel, ChannelType, PermissionFlagsBits, PermissionsBitField, Embed, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, OverwriteType } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("newsetup")
.setDMPermission(false)
.setDescription("פקודת סטאפ חדשה")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction, client) {

const components = new ComponentBuilder()
.setComponents([
new ContainerBuilder()
.setComponents([
new TextDisplay("Testing")
])
.setColor(1146986)
])


await interaction.reply(components.toJSON());
},
};
Used it as well, same thing occurs. And weirdly, the tutorial I tried did work for him
DanielBA
DanielBAOP3d ago
Oh, it seems like he is using a different package how should I write my componets variable then so this example will work? Can't open the video, seems to be an unsupported file type Can't find any player to view it, even online ones Alright, Changed the entire code. Now I recieve an error in the following line:
const container = new ContainerBuilder();
const container = new ContainerBuilder();
saying this is not a constructor again Not sure how can run the command in the host the ssh keeps timing out before I can do a thing
{
"name": "multi-loader",
"version": "1.0.0",
"description": "LA",
"main": "loader.js",
"scripts": {},
"author": "Jay Williams",
"license": "ISC",
"dependencies": {
"@napi-rs/canvas": "^0.1.44",
"axios": "^1.6.7",
"cheerio": "^1.0.0-rc.12",
"discord.js": "14.19.0",
"node-fetch": "^3.3.2",
"node-schedule": "^2.1.1",
"nodemon": "^3.0.1",
"rss-parser": "^3.13.0",
"sapphire": "^0.0.3",
"sequelize": "^6.37.0",
"sqlite3": "^5.1.7",
"systeminformation": "^5.21.22",
"discord-api-types": "0.38.1",
"@discordjs/builders": "1.11.1"
},
"nodeVersion": "23.1.0",
"file": "loader.js"
}
{
"name": "multi-loader",
"version": "1.0.0",
"description": "LA",
"main": "loader.js",
"scripts": {},
"author": "Jay Williams",
"license": "ISC",
"dependencies": {
"@napi-rs/canvas": "^0.1.44",
"axios": "^1.6.7",
"cheerio": "^1.0.0-rc.12",
"discord.js": "14.19.0",
"node-fetch": "^3.3.2",
"node-schedule": "^2.1.1",
"nodemon": "^3.0.1",
"rss-parser": "^3.13.0",
"sapphire": "^0.0.3",
"sequelize": "^6.37.0",
"sqlite3": "^5.1.7",
"systeminformation": "^5.21.22",
"discord-api-types": "0.38.1",
"@discordjs/builders": "1.11.1"
},
"nodeVersion": "23.1.0",
"file": "loader.js"
}
d.js docs
d.js docs3d ago
discord.js includes multiple sub-packages, installing these separately can mess with internal code:
npm uninstall discord-api-types @discordjs/rest @discordjs/builders
yarn remove discord-api-types @discordjs/rest @discordjs/builders
pnpm remove discord-api-types @discordjs/rest @discordjs/builders
npm uninstall discord-api-types @discordjs/rest @discordjs/builders
yarn remove discord-api-types @discordjs/rest @discordjs/builders
pnpm remove discord-api-types @discordjs/rest @discordjs/builders
DanielBA
DanielBAOP3d ago
Moved it back eariler to try both. The error happens on 14.19.1 as well Done, same error. not sure about the sapphire one as well but it seems to be the newest version
DanielBA
DanielBAOP3d ago
https://pastebin.com/BSQFwp7F error:
Uncaught rejection at: TypeError: ContainerBuilder is not a constructor
at Object.execute (/home/container/LiveAlertsTest/Commands/Staff/newSetup.js:11:25)
at module.exports (/home/container/LiveAlertsTest/Events/interactionCreate.js:6:17)
at Client.<anonymous> (/home/container/LiveAlertsTest/index.js:72:53)
at Client.emit (node:events:507:28)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:232:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:287:31)
at WebSocketShard.<anonymous> (/home/container/node_modules/@discordjs/ws/dist/index.js:1190:51)
Uncaught rejection at: TypeError: ContainerBuilder is not a constructor
at Object.execute (/home/container/LiveAlertsTest/Commands/Staff/newSetup.js:11:25)
at module.exports (/home/container/LiveAlertsTest/Events/interactionCreate.js:6:17)
at Client.<anonymous> (/home/container/LiveAlertsTest/index.js:72:53)
at Client.emit (node:events:507:28)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:232:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:287:31)
at WebSocketShard.<anonymous> (/home/container/node_modules/@discordjs/ws/dist/index.js:1190:51)
package.json:
{
"name": "multi-loader",
"version": "1.0.0",
"description": "LA",
"main": "loader.js",
"scripts": {},
"author": "Jay Williams",
"license": "ISC",
"dependencies": {
"@napi-rs/canvas": "^0.1.44",
"axios": "^1.6.7",
"cheerio": "^1.0.0-rc.12",
"discord.js": "14.19.1",
"node-fetch": "^3.3.2",
"node-schedule": "^2.1.1",
"nodemon": "^3.0.1",
"rss-parser": "^3.13.0",
"sapphire": "^0.0.3",
"sequelize": "^6.37.0",
"sqlite3": "^5.1.7",
"systeminformation": "^5.21.22"
},
"nodeVersion": "23.1.0",
"file": "loader.js"
}
{
"name": "multi-loader",
"version": "1.0.0",
"description": "LA",
"main": "loader.js",
"scripts": {},
"author": "Jay Williams",
"license": "ISC",
"dependencies": {
"@napi-rs/canvas": "^0.1.44",
"axios": "^1.6.7",
"cheerio": "^1.0.0-rc.12",
"discord.js": "14.19.1",
"node-fetch": "^3.3.2",
"node-schedule": "^2.1.1",
"nodemon": "^3.0.1",
"rss-parser": "^3.13.0",
"sapphire": "^0.0.3",
"sequelize": "^6.37.0",
"sqlite3": "^5.1.7",
"systeminformation": "^5.21.22"
},
"nodeVersion": "23.1.0",
"file": "loader.js"
}
Pastebin
const { MessageFlags, SeparatorSpacingSize, TextDisplayBuilder, Rol...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
DanielBA
DanielBAOP3d ago
Done and Done. it prints undefined for some reason. doing that right now Thanks, after downloading them all on my pc, compressing and extracting now i only seem to have missing import errors

Did you find this page helpful?