Soy nuevo en Discod.js v13. me sale este error
(async () => { ^ TypeError: (intermediate value) is not a functioneste es el codigo creo que es el problema
const rest = new REST({ version: "9" }).setToken("MyToken") (async () => {Si necesitas el código completo:
const { Client, Intents, Collection } = require("discord.js") const fs = require("fs") const {REST} = require("@discordjs/rest"); const {Routes} = require("discord-api-types/v9"); const client = new Client({ intents:[ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ] }) const BotName = "TestBot" const commandFiles = fs.readdirSync("./commands").filter(file => file.endsWith(".js")); const commands = [] client.commands = new Collection() for(const file of commandFiles){ const command = require("./commands/"+file) commands.push(command.data.toJSON()); client.commands.set(command.data.name, command) } client.once("ready", applicationId =>{ console.log(`${BotName} is now online`) const CLIENT_ID = client.user.id const rest = new REST({ version: "9" }).setToken("MyToken") (async () => { try{ if(process.env.ENV === "production"){ await rest.put(Routes.applicationCommands(CLIENT_ID), { body: commands }) console.log("Success command register globally") }else{ await rest.put(Routes.applicationGuildCommands(CLIENT_ID, process.env.GUILD_ID), { body: commands }) console.log("Success command register locally") } }catch(err){ console.log(err) } })(); }) client.on("interaction", async interaction =>{ if(!interaction.isCommand()) return const command = client.commands.get(interaction.commandName) if(!command) return try{ await command.execute(interaction); }catch(err){ console.log(err) await interaction.reply({ content: "ERROR" + err, ephemeral:true }) } }) client.login("MyToken")Como dije en mi comentario, este es un error relacionado con ASI (inserción automática de punto y coma). Lo verifiqué y después de poner un punto y coma después de }).setToken("MyToken"); funcionó bien
Utilice siempre punto y coma para evitar estos errores.