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

234
Views
How to .get() from Firebase to integrate in Discord.JS

I'm a new JavaScript programmer facing a problem that I can't seem to solve. I'm trying to save data in a Cloud Firestore Database using Firebase and trying to save and take data from the database. I've successfully created saving data as per this code below:

db.collection("data").doc(message.author.id).set({
            "userID": message.author.id,
            "userName": message.author.tag,
            "userWallet": 500,
            "userItems": {
                "DogeCoin": 0,
                "TrollCoin": 0,
                "TrollTrophy": 0
            },
            "lastClaim": 0,
            "lastCrime": 0
        }).then(() => {
            message.channel.send(`${message.author.tag}, you have successfully created your account.`)
        })

While the saving part works the getting data part doesn't, I've tried a few methods but it still doesn't work. Right now, this is what I've worked on.

let wallet;
            let bank;
            db.collection("data").doc(message.author.id).get().then((q) => {
                if (q.exists){
                    wallet = q.data().userWallet;
                } else if(!q.exists){
                    message.channel.send(`${message.author.tag}, please go create an account.`)
                    return;
                }
            })
            let embed = new Discord.MessageEmbed()
            .setTitle(`Balance for ${message.author.tag}`)
            .setAuthor(`${client.user.tag}`)
            .setColor("RANDOM")
            .setDescription(`Created by ${client.user.tag}`)
            .addFields(
                    {name: "Bank", value: `${wallet}`}
            )
            .setImage("https://c.tenor.com/iQ7AzP7EgSAAAAAM/noice.gif")
            message.reply({embeds: [embed]})
            return;

I want to able to get the data from Firebase and use it in my code by showing it in an embed. Your help in sincerely appreciated. Thank you.

An image to show the data saved in Firebase

about 4 years ago · Juan Pablo Isaza
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!