pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 1 | const {addLog} = require('../scripts/addLogs'); |
| 2 | const JsonDiff = require('json-diff'); |
| 3 | |
| 4 | module.exports = { |
| 5 | name:'guildMemberUpdate', |
| 6 | once:false, |
| 7 | async execute(oldMember, newMember) { |
| 8 | |
| 9 | let oMem = { |
| 10 | id: oldMember.id, |
| 11 | username: oldMember.user.username, |
| 12 | nick: oldMember.nickname, |
| 13 | roles: oldMember.roles.cache.map(r => r.id), |
| 14 | displayAvatarUrl: oldMember.displayAvatarUrl, |
| 15 | communicationDisabledUntil: oldMember.communicationDisabledUntilTimestamp |
| 16 | } |
| 17 | |
| 18 | let nMem = { |
| 19 | id: newMember.id, |
| 20 | username: newMember.user.username, |
| 21 | nick: newMember.nickname, |
| 22 | roles: newMember.roles.cache.map(r => r.id), |
| 23 | displayAvatarUrl: newMember.displayAvatarUrl, |
| 24 | communicationDisabledUntil: newMember.communicationDisabledUntilTimestamp |
| 25 | } |
| 26 | |
| 27 | let data = JsonDiff.diff(oMem, nMem, {full: true}); |
| 28 | |
| 29 | addLog(newMember.guild.id, data); |
| 30 | } |
| 31 | } |