partner tracking

master
Kit Kasune 3 years ago
parent 12bc171b12
commit 98fe91b9d0
  1. 2
      events/message.js
  2. 9
      models/partner.js
  3. 21
      util/newpartner.js

@ -65,6 +65,8 @@ module.exports = async (client, message) => {
});
}
if (message.guild && message.channel.id === "815709333107114043") {return require('../util/newpartner.js')(message, client);}
try {

@ -0,0 +1,9 @@
const mongoose = require('mongoose');
const Partners = new mongoose.Schema({
gid: {unique: true, type: String},
partners: {type: Object, default: {}},
total: {type: Number, default: 0}
});
module.exports = mongoose.model('partners', Partners);

@ -0,0 +1,21 @@
const Discord = require("discord.js");
const Partners = require('../models/partner');
module.exports = async (message, client) => {
let tp = await Partners.findOne({gid: message.guild.id}) || new Partners({gid: message.guild.id});
if (!Object.keys(tp.partners).includes(message.author.id)) {tp.partners[message.author.id] = 0;}
tp.partners[message.author.id] += 1;
tp.total += 1;
tp.markModified(`partners.${message.author.id}`);
tp.save();
return message.channel.send(new Discord.MessageEmbed()
.setTitle(`New Partner #${tp.total}!`)
.setThumbnail(message.guild.iconURL({size: 1024, dynamic: true}))
.setDescription(`PM: ${message.member.displayName} || <@${message.member.id}>\nTheir partner count: ${tp.partners[message.author.id]}`)
.setImage("https://cdn.discordapp.com/attachments/821171356820963328/847607981247561758/20210504_174641.gif")
.setColor('52c7bb')
.setFooter("Luno", client.user.avatarURL())
.setTimestamp()
);
};
Loading…
Cancel
Save