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