.toJSON() throws TypeError #6988
-
Issue descriptionWhen running below script, the line How to reproduce:
Code sampleconst fs = require('fs');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const clientId = 'client id here';
const guildId = 'guild id here';
const token = 'token here';
const commands = [];
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}
const rest = new REST({ version: '9' }).setToken(token);
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then(() => console.log('Successfully registered application commands.'))
.catch(console.error); discord.js version13.3.1 Node.js version17.1.0 Operating systemLinux, Windows Priority this issue should haveMedium (should be fixed soon) Which partials do you have configured?No Partials Which gateway intents are you subscribing to?GUILDS I have tested this issue on a development releaseNo response |
Beta Was this translation helpful? Give feedback.
Answered by
vladfrangu
Nov 15, 2021
Replies: 1 comment 3 replies
-
I don't see how this is related to discord.js. This is your code not exporting the data property of, what I assume is, an @discordjs/builder instance |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
jaezudev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't see how this is related to discord.js. This is your code not exporting the data property of, what I assume is, an @discordjs/builder instance