Invalid Form body

await rest.put(
Routes.applicationCommands(BOT_ID),
{body: client.slashCommands},
);
await rest.put(
Routes.applicationCommands(BOT_ID),
{body: client.slashCommands},
);
49 Replies
d.js toolkit
d.js toolkitβ€’15mo 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!
CrypLemonade
CrypLemonadeβ€’15mo ago
const {REST} = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v8');
require('dotenv').config();
const {BOT_ID} = process.env;
const fs = require("fs");

module.exports = (client) => {
client.handleCommands = async () => {
const commandFolders = fs.readdirSync('./src/commands');
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./src/commands/${folder}`)
.filter((file) => file.endsWith(".js"));

const {commands, slashCommands} = client;
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${folder}/${file}`);
slashCommands.push(command.data.toJSON());
commands.set(command.data.name, command);
console.log(`${command.data.name} Has successfully been loaded!`)
}
}

// const clientId = '913115402761039873';
const rest = new REST ({version: '9'}).setToken(process.env.TOKEN);
try {
console.log('Refreshing Application Commands. (/)');

await rest.put(
Routes.applicationCommands(BOT_ID),
{body: client.slashCommands},
);

console.log('Successfully Refreshed Application Commands. (/)');
} catch (error) {
console.error(error);
}
}
}
const {REST} = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v8');
require('dotenv').config();
const {BOT_ID} = process.env;
const fs = require("fs");

module.exports = (client) => {
client.handleCommands = async () => {
const commandFolders = fs.readdirSync('./src/commands');
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./src/commands/${folder}`)
.filter((file) => file.endsWith(".js"));

const {commands, slashCommands} = client;
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${folder}/${file}`);
slashCommands.push(command.data.toJSON());
commands.set(command.data.name, command);
console.log(`${command.data.name} Has successfully been loaded!`)
}
}

// const clientId = '913115402761039873';
const rest = new REST ({version: '9'}).setToken(process.env.TOKEN);
try {
console.log('Refreshing Application Commands. (/)');

await rest.put(
Routes.applicationCommands(BOT_ID),
{body: client.slashCommands},
);

console.log('Successfully Refreshed Application Commands. (/)');
} catch (error) {
console.error(error);
}
}
}
Ive changed the code a few times and it just doesnt want to work
treble/luna
treble/lunaβ€’15mo ago
your client id is undefined
CrypLemonade
CrypLemonadeβ€’15mo ago
Alright, ive fixed that but now i get this?
CrypLemonade
CrypLemonadeβ€’15mo ago
CrypLemonade
CrypLemonadeβ€’15mo ago
has 'rest.put' been changed or something because all of the errors origin there
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
do I need to do that with the routes too?
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docsβ€’15mo 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
CrypLemonade
CrypLemonadeβ€’15mo ago
thanks for that but its still giving the error?
CrypLemonade
CrypLemonadeβ€’15mo ago
const {REST, Routes} = require('discord.js');
require('dotenv').config();
const fs = require("fs");

module.exports = (client) => {
client.handleCommands = async () => {
const commandFolders = fs.readdirSync('./src/commands');
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./src/commands/${folder}`)
.filter((file) => file.endsWith(".js"));

const {commands, slashCommands} = client;
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${folder}/${file}`);
slashCommands.push(command.data.toJSON());
commands.set(command.data.name, command);
console.log(`${command.data.name} Has successfully been loaded!`)
}
}

const clientId = '913115402761039873';
const rest = new REST ({version: '9'}).setToken(process.env.TOKEN);
try {
console.log('Refreshing Application Commands. (/)');

await rest.put(
Routes.applicationCommands(clientId),
{body: client.slashCommands},
);

console.log('Successfully Refreshed Application Commands. (/)');
} catch (error) {
console.error(error);
}
}
}
const {REST, Routes} = require('discord.js');
require('dotenv').config();
const fs = require("fs");

module.exports = (client) => {
client.handleCommands = async () => {
const commandFolders = fs.readdirSync('./src/commands');
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./src/commands/${folder}`)
.filter((file) => file.endsWith(".js"));

const {commands, slashCommands} = client;
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${folder}/${file}`);
slashCommands.push(command.data.toJSON());
commands.set(command.data.name, command);
console.log(`${command.data.name} Has successfully been loaded!`)
}
}

const clientId = '913115402761039873';
const rest = new REST ({version: '9'}).setToken(process.env.TOKEN);
try {
console.log('Refreshing Application Commands. (/)');

await rest.put(
Routes.applicationCommands(clientId),
{body: client.slashCommands},
);

console.log('Successfully Refreshed Application Commands. (/)');
} catch (error) {
console.error(error);
}
}
}
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
for which package? djs?
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
that?
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
didnt mean delete the brackets ahah
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
yeah
CrypLemonade
CrypLemonadeβ€’15mo ago
CrypLemonade
CrypLemonadeβ€’15mo ago
done
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
I'm sorry about all this btw, I haven't really done much DJS since like- late V12 ahah
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
Ive got auto save on
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
like that??
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
like that?
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
isnt itπŸ₯²?
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
OHHH
CrypLemonade
CrypLemonadeβ€’15mo ago
Im confused, I added console.error(error) and now nothing shows
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
as in,, in the console?
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
CrypLemonade
CrypLemonadeβ€’15mo ago
nope
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonadeβ€’15mo ago
Yeah, thats fine, I understand haha its 1:22am here so yeah, thanks for your help πŸ˜„
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server