const Discord = require('discord.js'); const { client, logger } = require('../index'); const Enmap = require('enmap'); const { updateRoles } = require('./karma'); const stats = new Enmap({name: 'carlos_stats'}); let uID = '566239971309256704'; let guildID = '653568812578373643'; let muteRoleID = '751522580300693608'; let statusRoleID = '795371115513249862'; module.exports.run = () => { } /** * This counts how often a specific user got banned/muted. */ if (stats.get('bans') == undefined) stats.set('bans', process.env.CARLOS_BANS || 0); if (stats.get('mutes') == undefined) stats.set('mutes', process.env.CARLOS_MUTES || 0); client.on('guildBanAdd', (guild, user) => { if (user.id != uID) return; stats.set('bans', stats.get('bans') + 1); updateRole(); }); client.on('guildMemberUpdate', (oldMember, newMember) => { if (newMember.id != uID) return; if (!oldMember.roles.cache.get(muteRoleID) && newMember.roles.cache.get(muteRoleID)) { stats.set('mutes', stats.get('mutes') + 1); updateRole(); } }); client.on('guildMemberAdd', (member) => { if (member.id == uID) member.roles.add(muteRoleID).catch(e => logger.warn(`Failed to assign role ${muteRoleID}: ${e}`)); }); let updateRole = () => { let role = client.guilds.cache.get(guildID).roles.cache.get(statusRoleID); if (!role) return; if (role.editable) role.setName(`${stats.get('bans')} bans, ${stats.get('mutes')} mutes`, 'Carlos is a dipfuck'); else logger.warn('Can\'t manage role ' + statusRoleID); }