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

Did you find this page helpful?