is this working?

mail@pastecode.io avatar
unknown
javascript
2 years ago
1.2 kB
4
Indexable
Never
  const client = message.client
    const guildDB = await Guild.findOne({
        guildId: message.guild.id
    });
    const errorEmbed = new discord.MessageEmbed().setAuthor(`${message.author.tag}`, message.author.displayAvatarURL({ format: 'png'})).setColor(client.color.red).setFooter("https://potatocrafts.tk").setTimestamp()
    const successEmbed = new discord.MessageEmbed().setAuthor(`${message.author.tag}`, message.author.displayAvatarURL({ format: 'png'})).setColor(client.color.green).setFooter("https://potatocrafts.tk").setTimestamp()

    
    let user = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member

    let amountOfMoney


    await bal.findOne({ user: user.user.id }, async (err, db) => {
      if(!db) {
        new bal({
          user: user.id,
          balance: 0
        })
        .save()
        .catch(err => { return message.channel.send(`I have encountered an error -> ${err}`)})
        amountOfMoney = 0
      } else {
        amountOfMoney = db.balance
      }

      message.channel.send(successEmbed.setTitle(`${user.user.username}'s Balance`).setDescription(`-> ${amountOfMoney} <:coin:822159088221814836>`)
)
    })