From dd64dac7acb4ca427af261cfbd3493f661bce9e4 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Fri, 19 Feb 2021 16:56:22 -0700 Subject: [PATCH] hug counter --- commands/hug.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/commands/hug.js b/commands/hug.js index 340fe5b..0dfd2b7 100644 --- a/commands/hug.js +++ b/commands/hug.js @@ -1,6 +1,9 @@ const Discord = require('discord.js'); + const Saves = require('../models/saves'); const UserData = require('../models/user'); +const VC = require('../models/vscount'); + const makeId = require('../util/makeid'); module.exports = { @@ -29,10 +32,17 @@ module.exports = { if (!message.guild) {return message.reply("Please make sure you're in a server so you can mention someone other than me to hug!");} if (!message.guild.members.cache.has(mention.id)) {return message.reply("That user is not in this server!");} if (message.author.id === mention.id) {return message.reply("Sorry if you're that lonely, but you can't hug yourself!");} + let hugs = await VC.findOne({uid: message.author.id, countOf: 'hug'}) || new VC({uid: message.author.id, countOf: 'hug'}); + hugs.against[mention.id] = hugs.against[mention.id] ? hugs.against[mention.id] + 1 : 1; + hugs.total++; + hugs.markModified(`against.${mention.id}`); + hugs.save(); return message.channel.send(new Discord.MessageEmbed() .setAuthor(`${message.guild ? message.member.displayName : message.author.username} gives ${message.guild.members.cache.get(mention.id).displayName} a hug!`, message.author.avatarURL()) + .setDescription(`You've hugged them **${hugs.total === 1 ? 'once' : `${hugs.total} times!`}**`) .setImage(String(Array.from(saves.values())[Math.floor(Math.random() * saves.size)])) .setColor('52c7bb') + .setFooter(`${hugs.total} hug${hugs.total === 1 ? '' : 's'} total`) ); } if (['s', 'save', 'n', 'new', 'a', 'add'].includes(args[0].toLowerCase())) {