Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

307
Views
Discord.js v13 (valor intermedio).setToken(...) no es una función

Soy nuevo en Discod.js v13. me sale este error

 (async () => { ^ TypeError: (intermediate value) is not a function

este 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")
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!