Slash Command Error - I have no idea why

current problem is between data.js in command folder and index.js There are 2 problem. First is Warning: Accessing non-existent property 'database' of module exports inside circular dependency it seem like it cant database property in index? and get data from data folder? Second is I do not know what wrong with my data.js? console log:
root@API:~/discord_bot# node index.js
(node:7813) Warning: Accessing non-existent property 'database' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Bot is now online!
/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50035]: Invalid Form Body
0.name[BASE_TYPE_REQUIRED]: This field is required
at handleErrors (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.runRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1072:23)
at async SequentialHandler.queueRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:913:14)
at async _REST.request (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ApplicationCommandManager.set (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:171:18) {
requestBody: {
files: undefined,
json: [
{
name: undefined,
name_localizations: undefined,
description: undefined,
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
},
{
name: 'ping',
name_localizations: undefined,
description: 'Replies with "pong!"',
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
}
]
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
'0': { name: { _errors: [ [Object] ] } }
}
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1044260619894931506/commands'
}
root@API:~/discord_bot# node index.js
(node:7813) Warning: Accessing non-existent property 'database' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Bot is now online!
/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50035]: Invalid Form Body
0.name[BASE_TYPE_REQUIRED]: This field is required
at handleErrors (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.runRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1072:23)
at async SequentialHandler.queueRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:913:14)
at async _REST.request (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ApplicationCommandManager.set (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:171:18) {
requestBody: {
files: undefined,
json: [
{
name: undefined,
name_localizations: undefined,
description: undefined,
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
},
{
name: 'ping',
name_localizations: undefined,
description: 'Replies with "pong!"',
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
}
]
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
'0': { name: { _errors: [ [Object] ] } }
}
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1044260619894931506/commands'
}
10 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
Not Toby
Not TobyOP15mo ago
fixed first one, still no have idea why invalid form body
Not Toby
Not TobyOP15mo ago
Lastest code
Not Toby
Not TobyOP15mo ago
Error log:
root@API:~/discord_bot# node index.js
Bot is now online!
/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50035]: Invalid Form Body
0.name[BASE_TYPE_REQUIRED]: This field is required
at handleErrors (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.runRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1072:23)
at async SequentialHandler.queueRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:913:14)
at async _REST.request (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ApplicationCommandManager.set (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:171:18) {
requestBody: {
files: undefined,
json: [
{
name: undefined,
name_localizations: undefined,
description: undefined,
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
}
]
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
'0': { name: { _errors: [ [Object] ] } }
}
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1044260619894931506/commands'
}
root@API:~/discord_bot# node index.js
Bot is now online!
/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50035]: Invalid Form Body
0.name[BASE_TYPE_REQUIRED]: This field is required
at handleErrors (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.runRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1072:23)
at async SequentialHandler.queueRequest (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:913:14)
at async _REST.request (/root/discord_bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ApplicationCommandManager.set (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:171:18) {
requestBody: {
files: undefined,
json: [
{
name: undefined,
name_localizations: undefined,
description: undefined,
nsfw: undefined,
description_localizations: undefined,
type: undefined,
options: undefined,
default_member_permissions: undefined,
dm_permission: undefined
}
]
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
'0': { name: { _errors: [ [Object] ] } }
}
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1044260619894931506/commands'
}
Tribe
Tribe15mo ago
Looks like you arent passing anything into await existingCommand.edit(); which would explain why your payload to register the command is completely undefined
Not Toby
Not TobyOP15mo ago
how can i fix it, is there any example
Tribe
Tribe15mo ago
I would just pass in the edits as an object
await existingCommand.edit({
name: 'enter your name',
description: 'enter your desc',
options: your options,
})
await existingCommand.edit({
name: 'enter your name',
description: 'enter your desc',
options: your options,
})
Not Toby
Not TobyOP15mo ago
i change client.application.commands.set(commands); to client.application.commands.set(commands.map(c => c.data)); and it work... but now i have new error
root@API:~/discord_bot# node index.js
Bot is now online!
/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:236
if ('default_member_permissions' in command) {
^

TypeError: Cannot use 'in' operator to search for 'default_member_permissions' in undefined
at Function.transformCommand (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:236:38)
at /root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:172:48
at Array.map (<anonymous>)
at ApplicationCommandManager.set (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:172:22)
at Client.<anonymous> (/root/discord_bot/index.js:51:31)
at Client.emit (node:events:513:28)
at WebSocketManager.triggerClientReady (/root/discord_bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:388:17)
at WebSocketManager.checkShardsReady (/root/discord_bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:371:10)
at WebSocketShard.<anonymous> (/root/discord_bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:201:16)
at WebSocketShard.emit (node:events:513:28)
root@API:~/discord_bot# node index.js
Bot is now online!
/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:236
if ('default_member_permissions' in command) {
^

TypeError: Cannot use 'in' operator to search for 'default_member_permissions' in undefined
at Function.transformCommand (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:236:38)
at /root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:172:48
at Array.map (<anonymous>)
at ApplicationCommandManager.set (/root/discord_bot/node_modules/discord.js/src/managers/ApplicationCommandManager.js:172:22)
at Client.<anonymous> (/root/discord_bot/index.js:51:31)
at Client.emit (node:events:513:28)
at WebSocketManager.triggerClientReady (/root/discord_bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:388:17)
at WebSocketManager.checkShardsReady (/root/discord_bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:371:10)
at WebSocketShard.<anonymous> (/root/discord_bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:201:16)
at WebSocketShard.emit (node:events:513:28)
@TAEMBOO you can check this source
TÆMBØ
TÆMBØ15mo ago
It looks like you're just trying to register the entire contents of each command, including its execute function
Not Toby
Not TobyOP15mo ago
uhh i have no idea, let me try rewrite it
Want results from more Discord servers?
Add your server