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•10mo 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•10mo 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•10mo ago
your client id is undefined
CrypLemonade
CrypLemonade•10mo ago
Alright, ive fixed that but now i get this?
CrypLemonade
CrypLemonade•10mo ago
CrypLemonade
CrypLemonade•10mo ago
has 'rest.put' been changed or something because all of the errors origin there
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
do I need to do that with the routes too?
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs•10mo 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•10mo ago
thanks for that but its still giving the error?
CrypLemonade
CrypLemonade•10mo 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•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
for which package? djs?
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
that?
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
didnt mean delete the brackets ahah
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
yeah
CrypLemonade
CrypLemonade•10mo ago
CrypLemonade
CrypLemonade•10mo ago
done
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
I'm sorry about all this btw, I haven't really done much DJS since like- late V12 ahah
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
Ive got auto save on
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
like that??
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
like that?
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
isnt it🥲?
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
OHHH
CrypLemonade
CrypLemonade•10mo ago
Im confused, I added console.error(error) and now nothing shows
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
as in,, in the console?
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
CrypLemonade
CrypLemonade•10mo ago
nope
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
CrypLemonade
CrypLemonade•10mo ago
Yeah, thats fine, I understand haha its 1:22am here so yeah, thanks for your help 😄
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View