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•11mo 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•11mo ago
log interaction.constructor.name
Zanoriks
Zanoriks•11mo ago
Client
treble/luna
treble/luna•11mo ago
well then you pass in a client in your command handler, not an interaction
d.js docs
d.js docs•11mo 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
Zanoriks•11mo 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•11mo 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
Zanoriks•11mo ago
client.on(handlerName, async (...args) => await handler(...args));
client.on(handlerName, async (...args) => await handler(...args));
Zanoriks
Zanoriks•11mo ago
treble/luna
treble/luna•11mo ago
show interactionCreate line 62 and around
Zanoriks
Zanoriks•11mo ago
treble/luna
treble/luna•11mo ago
you did not define logger
Zanoriks
Zanoriks•11mo ago
in handler?
treble/luna
treble/luna•11mo ago
wherever you construct client but i dont see the need of a logger when you can just use console.error
Zanoriks
Zanoriks•11mo ago
I think I'm giving up because I don't know what to do anymore ;/ still error same
SpecialSauce
SpecialSauce•11mo ago
Just use console.error instead of client.logger?
Zanoriks
Zanoriks•11mo ago
treble/luna
treble/luna•11mo ago
show the relevant code
Zanoriks
Zanoriks•11mo ago
which?
treble/luna
treble/luna•11mo ago
interactionC<reate line 9 as you can also see from your error
Zanoriks
Zanoriks•11mo ago
treble/luna
treble/luna•11mo ago
waitWhat removed client from your handler yet you added it there? this is basic js at this point
Zanoriks
Zanoriks•11mo ago
I forgot about that kekw should i remove the client from everything? messageCreate.js etc...
treble/luna
treble/luna•11mo ago
if you removed it in your handler yes Most dhs structures have a client property
Zanoriks
Zanoriks•11mo ago
I deleted the client
Zanoriks
Zanoriks•11mo ago
Zanoriks
Zanoriks•11mo ago
ehh
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs•11mo 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