why am i getting this error?

Pastebin
const { SlashCommandBuilder } = require('@discordjs/builders');cons...
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.
30 Replies
d.js toolkit
d.js toolkitβ€’2y ago
- What's your exact discord.js npm list discord.js and node node -v version? - Post the full error stack trace, not just the top part! - Show your code! - Explain what exactly your issue is. - Not a discord.js issue? Check out #useful-servers. - Issue solved? Press the button!
treble/luna
treble/lunaβ€’2y ago
log interaction.constructor.name
Zanoriks
ZanoriksOPβ€’2y ago
Client
treble/luna
treble/lunaβ€’2y ago
well then you pass in a client in your command handler, not an interaction
d.js docs
d.js docsβ€’2y ago
The order of function parameters must match between definition and function call.
function execute(client, interaction) { ... };
execute(interaction, client);
function execute(client, interaction) { ... };
execute(interaction, client);
- mismatch! you pass an interaction where the client is expected - mismatch! you pass the client where an interaction is expected
Zanoriks
ZanoriksOPβ€’2y ago
const { readdirSync } = require("node:fs");
const { join, resolve } = require("path");

const handlers = {
events: {
path: resolve("events"),
subfolders: false
},
commands: {
path: resolve("interactions", "commands"),
subfolders: true
},
buttons: {
path: resolve("interactions", "buttons"),
subfolders: false
},
modals: {
path: resolve("interactions", "modals"),
subfolders: false
}
}

module.exports = async client => {
for (const [type, { path, subfolders }] of Object.entries(handlers)) {
const files = readdirSync(path);

for (const file of files) {
let handlerName = file

if (subfolders) {
const subfolders = readdirSync(join(path, handlerName));

for (const subfolder of subfolders) {
const subfolderHandler = require(join(path, handlerName, subfolder));
subfolderHandler.category = handlerName;

client[type].set(subfolderHandler.data.toJSON().name, subfolderHandler);
client.logger[type]++;
}
} else {
const handler = require(join(path, file));
handlerName = file.replace('.js', '');

if (type != "events") client[type].set(handler.name, handler);
else client.on(handlerName, async (...args) => await handler(client, ...args));

client.logger[type]++;
}
}
}
};
const { readdirSync } = require("node:fs");
const { join, resolve } = require("path");

const handlers = {
events: {
path: resolve("events"),
subfolders: false
},
commands: {
path: resolve("interactions", "commands"),
subfolders: true
},
buttons: {
path: resolve("interactions", "buttons"),
subfolders: false
},
modals: {
path: resolve("interactions", "modals"),
subfolders: false
}
}

module.exports = async client => {
for (const [type, { path, subfolders }] of Object.entries(handlers)) {
const files = readdirSync(path);

for (const file of files) {
let handlerName = file

if (subfolders) {
const subfolders = readdirSync(join(path, handlerName));

for (const subfolder of subfolders) {
const subfolderHandler = require(join(path, handlerName, subfolder));
subfolderHandler.category = handlerName;

client[type].set(subfolderHandler.data.toJSON().name, subfolderHandler);
client.logger[type]++;
}
} else {
const handler = require(join(path, file));
handlerName = file.replace('.js', '');

if (type != "events") client[type].set(handler.name, handler);
else client.on(handlerName, async (...args) => await handler(client, ...args));

client.logger[type]++;
}
}
}
};
my handler.js how do i fix it?
treble/luna
treble/lunaβ€’2y ago
either remove the client, or pass in your params properly the first is the better since you can access it from your interaction
Zanoriks
ZanoriksOPβ€’2y ago
client.on(handlerName, async (...args) => await handler(...args));
client.on(handlerName, async (...args) => await handler(...args));
Zanoriks
ZanoriksOPβ€’2y ago
treble/luna
treble/lunaβ€’2y ago
show interactionCreate line 62 and around
Zanoriks
ZanoriksOPβ€’2y ago
treble/luna
treble/lunaβ€’2y ago
you did not define logger
Zanoriks
ZanoriksOPβ€’2y ago
in handler?
treble/luna
treble/lunaβ€’2y ago
wherever you construct client but i dont see the need of a logger when you can just use console.error
Zanoriks
ZanoriksOPβ€’2y ago
I think I'm giving up because I don't know what to do anymore ;/ still error same
SpecialSauce
SpecialSauceβ€’2y ago
Just use console.error instead of client.logger?
Zanoriks
ZanoriksOPβ€’2y ago
treble/luna
treble/lunaβ€’2y ago
show the relevant code
Zanoriks
ZanoriksOPβ€’2y ago
which?
treble/luna
treble/lunaβ€’2y ago
interactionC<reate line 9 as you can also see from your error
Zanoriks
ZanoriksOPβ€’2y ago
treble/luna
treble/lunaβ€’2y ago
waitWhat removed client from your handler yet you added it there? this is basic js at this point
Zanoriks
ZanoriksOPβ€’2y ago
I forgot about that kekw should i remove the client from everything? messageCreate.js etc...
treble/luna
treble/lunaβ€’2y ago
if you removed it in your handler yes Most dhs structures have a client property
Zanoriks
ZanoriksOPβ€’2y ago
I deleted the client
Zanoriks
ZanoriksOPβ€’2y ago
Zanoriks
ZanoriksOPβ€’2y ago
ehh
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docsβ€’2y ago
In JavaScript, = is used for assignment, == for loose equality, and === for strict equality checks.
x = 1; // assigning x to a value
'1' == 1 // true
'1' === 1 // false
x = 1; // assigning x to a value
'1' == 1 // true
'1' === 1 // false
- Equality and sameness in JavaScript: learn more
Want results from more Discord servers?
Add your server