Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
Pescado comando discord.js

Así que estaba tratando de hacer un comando de pesca sin un controlador, y encontré un problema: incluso si compro una caña de pescar en la tienda, dice que no tengo una caña de pescar. Aquí está el código-

 client.on("message", async message => { if(message.content === "$fish") { const cooldown = db.get(`fishCheck_${message.author.id}`) const timeout = 900000; if (cooldown !== null && timeout - (Date.now() - cooldown) > 0) { const ms = require('pretty-ms') const timeLeft = ms(timeout - (Date.now() - cooldown)) let manga = new Discord.MessageEmbed() .setTitle("You cant fish right now") .setColor("RED") .setDescription(`You fished just some time ago and need to wait ${timeLeft} for fishing again.`) .setTimestamp() message.reply({embeds : [manga]}) } else { const itemlol = await db.get(`items_fishingrod_${message.author.id}`) if (itemlol > 0) { let percenthandle = Math.floor(Math.random() * 100) + 1 if (percenthandle < 101 && percenthandle > 49) { let fishdom = Math.floor(Math.random() * 10000) + 1000 let balance = db.get(`wallet_${message.author.id}`) let money = balance + fishdom db.set(`wallet_${message.author.id}`, money) ; message.reply(`You went fishing, and were only able to catch very less fish, which you sold and got ${fishdom}`) } if (percenthandle < 50 && percenthandle > 5) { let fishdom = Math.floor(Math.random() * 100000) + 10000 let balance = db.get(`wallet_${message.author.id}`) let money = balance + fishdom db.set(`wallet_${message.author.id}`, money) ; message.reply(`You went fishing, and caught a decent amount of fish, which you sold and got ${fishdom}`) } if (percenthandle < 6 && percenthandle > 0) { let fishdom = Math.floor(Math.random() * 1000000) + 100000 let balance = db.get(`wallet_${message.author.id}`) let money = balance + fishdom db.set(`wallet_${message.author.id}`, money) ; message.reply(`You went fishing, and caught a whole ARMY of fish, which you sold and got ${fishdom}`) } db.set(`fishCheck_${message.author.id}`, Date.now()) } else { let fishEmbedError = new Discord.MessageEmbed() .setTitle("Item not found") .setDescription("You do not have a fishing rod to fish! Buy one from the shop and try this command again") .setColor("RED") .setFooter("I wanna fish with hand xd") message.channel.send({embeds :[fishEmbedError]}) } } } })

¿Alguien puede decir dónde me equivoqué?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Dang, este código es complicado LOL, pero ¿no deberías verificar si el usuario tiene una caña de pescar al principio? también sugeriría usar try catch ya que es más fácil de leer y no bloquea tu bot. Por ejemplo, podrías hacer algo como:

 try{ //code here.. }catch(err){ console.log(err) }

También le brinda más detalles sobre su error, siento que hay algo mal con sus declaraciones IF y ELSE, pero aún no puedo verlo.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda