Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

237
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda