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

141
Views
Fish command discord.js

So I was trying to make a fishing command without a handler, and I ran across a problem- Even if I buy fishing rod from shop, it says I don't have a fishing rod. Here is the code-

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]})
        
      }
  }
}
})

Can anyone tell where I went wrong?

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

0

Dang this code is messy LOL, but shouldn't you check if user has a fishing rod at the start? also I'd suggest using try catch since It's easier to read and It doesn't brick your bot. For example you could do something like:

    try{

  //code here..

  }catch(err){
    console.log(err)
  }

It also gives you more details about your error, I feel like there's something wrong with your IF & ELSE statements but I just can't see it yet

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!