Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
801 views
in Technique[技术] by (71.8m points)

discord.js - Reputation system with mongodb

was trying to make a reputation system where one user marked the other with the command for example: !rep @user

and the checked user gained 1 reputation

but every time I mention the user the reputation comes to me and not to the user, can someone help me?

it is a very practical system, but I am not managing to fix just this problem, I have tried for several hours, there is no error in the terminal it only delivers the reputation to me when it was for him to deliver the reputation to the user I mentioned.


const {MessageEmbed} = require("discord.js");
const ms = require("parse-ms");
const mongoose = require("mongoose");
const config = require('../../config.json')

const fairys = require("../../mongodb/money.js");

module.exports.run = async (client, message, args, prefix) => {

  let user = message.mentions.members.first();
    let timeout = 3600000;
    let amount = 1;
    fairys.updateMany({ User: user.id, rep: amount })
    fairys.findOne({ User: message.author.id },async(err, data)=>{
      if(err) message.reply(err)
      if (!data) {
        let newEconomy = new fairys({
          User: message.author.id,
          Tag: message.author.tag,
          RepTime: Date.now()
      }).save();

        
      let economyEmbed = new MessageEmbed()
      .setTitle('Reputa??o | Erza')
      .setThumbnail(message.author.displayAvatarURL({format: "png"}))
      .setFooter('Vocês receberam 200 Fairys pela reputa??o!')
      .setDescription(`<:aproved:789172167169933353> **<@${user.id}>**, Você acaba de receber um ponto de reputa??o!
Agrade?a a <@${message.author.id}> por mais um ponto de reputa??o!`)
      .setFooter(`Requisitado por ${message.author.tag}`)
      .setTimestamp()
      message.quote(economyEmbed)
      
    } else {
      if (data.RepTime !== null && timeout - (Date.now() - data.RepTime) > 0) {

        let time = ms(timeout - (Date.now() - data.RepTime));

        let timeEmbed = new MessageEmbed()
        .setColor('#e32136')
      .setTitle('Reputa??o | Erza')
      .setThumbnail(message.author.displayAvatarURL({format: "png"}))
      .setDescription(`<:danied:790608987430322206> **${message.author.username}**,
Você já deu **Reputa??o** para um membro hoje.
 Para dar reputa??o novamente aguarde **${time.hours}:${time.minutes}:${time.seconds}**.`)
      .setFooter(`Requisitado por ${message.author.tag}`)
      .setTimestamp()
        message.quote(timeEmbed)
      } else {

        if(!args[0]) return message.reply(`**${message.author.username}**, Você pode dar reputa??o pra alguém agora!,
Você precisa mencionar o usuário para dar reputa??o!`);
        let user = message.mentions.users.first() || client.users.get(args[0]);
        if (user.bot) return message.reply(`**${message.author.username}**, Você n?o pode dar reputa??o a um bot`);

        data.rep = data.rep + amount;
        data.RepTime = Date.now();
        data.save()
        let economyEmbed = new MessageEmbed()
        .setColor('#e32136')
    .setTitle('Reputa??o | Erza')
    .setThumbnail(message.author.displayAvatarURL({format: "png"}))
    .setFooter('Vocês receberam 200 Fairys pela reputa??o!')
    .setDescription(`<:aproved:789172167169933353> **<@${user.id}>**, Você acaba de receber um ponto de reputa??o!
Agrade?a a <@${message.author.id}> por mais um ponto de reputa??o!`)
    .setFooter(`Requisitado por ${message.author.tag}`)
    .setTimestamp()
        message.quote(economyEmbed)
    }
  }
});
}
exports.help = {
    name: 'rep',
    aliases: [],
    category: 'economy'
} 
question from:https://stackoverflow.com/questions/65879288/reputation-system-with-mongodb

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...