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

178
Views
No puedo iniciar mi bot, dice SyntaxError: el identificador 'incrustar' ya ha sido declarado

aquí están los códigos, estoy usando replit discord.js

 const config = require('./config'); const commands = require('./help'); let bot = new Client({ fetchAllMembers: true, // Remove this if the bot is in large guilds. presence: { status: 'online', activity: { name: `${config.prefix} help`, type: 'LISTENING' } } }); bot.on('ready', () => console.log(`Logged in as ${bot.user.tag}.`)); bot.on('message', async message => { // Check for command if (message.content.startsWith(config.prefix)) { let args = message.content.slice(config.prefix.length).split(' '); let command = args.shift().toLowerCase(); switch (command) { case 'avatar': const Discord = require("discord.js"); let user = message.mentions.users.first() || message.author; let avatar = user.displayAvatarURL({size: 4096, dynamic: true}); let embed = new Discord.MessageEmbed() .setTitle(`Avatar de ${user.tag}` ) .setURL(avatar) .setImage(avatar) .setColor('RANDOM') .setDescription('Ton avatar :') message.channel.send(embed) case 'ping': let msg = await message.reply('Pinging...'); await msg.edit(`PONG! Message round-trip took ${Date.now() - msg.createdTimestamp}ms.`) break; case 'repeat': if (args.length > 0) message.channel.send(args.join(' ')); else message.reply('You did not send a message to repeat, please try again.') break /* Unless you know what you're doing, don't change this command. */ case 'help': let embed = new MessageEmbed() .setTitle('Help Menu') .setColor('BLUE') .setFooter(`Requested by: ${message.member ? message.member.displayName : message.author.username}`, message.author.displayAvatarURL()) .setThumbnail(bot.user.displayAvatarURL()); //29 more...

cada vez que intenté iniciar el bot, dijo: 'Error de sintaxis: el identificador 'incrustar' ya se ha declarado', luego se bloqueó, también intenté hacer la inserción para embed1 pero rompió el código, por favor alguien que me ayude

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La variable embed se declara dos veces en el mismo ámbito. Tienes dos opciones:

Opción 1. Declararlo una vez antes de la declaración de switch . Recuerde que todos los casos del interruptor están en el mismo alcance.

 let embed; switch (command) { case 1: embed = new Embed(); embed.doSomething(); break; case 2: embed = new AnotherEmbed(); break; }

Opción 2. Cree un nuevo alcance para cada declaración de case , rodeándolos con llaves y luego declare esa variable independientemente en cada alcance:

 switch (command) { case 1: { const embed = new Embed(); embed.doSomething(); break; } case 2: { const embed = new AnotherEmbed(); break; } }
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!