magic
This commit is contained in:
parent
0af48d3f0b
commit
c9d19e77ff
|
@ -16,25 +16,39 @@ module.exports.run = () => {
|
||||||
* This counts how often a specific user got banned/muted.
|
* 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('bans') == undefined) stats.set('bans', 0);
|
||||||
if (stats.get('mutes') == undefined) stats.set('mutes', process.env.CARLOS_MUTES || 0);
|
if (stats.get('mutes') == undefined) stats.set('mutes', 0);
|
||||||
|
|
||||||
|
try {
|
||||||
|
let role = client.guilds.cache.get(guildID).roles.cache.get(statusRoleID), roleName = role.name;
|
||||||
|
let [bans, mutes] = roleName.split(' bans, ');
|
||||||
|
mutes = Number(mutes.split(' mutes')[0]);
|
||||||
|
bans = Number(bans);
|
||||||
|
if (mutes != undefined && bans != undefined) {
|
||||||
|
stats.set('bans', bans);
|
||||||
|
stats.set('mutes', mutes);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
logger.warn('Failed to parse role name: ' + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
client.on('guildBanAdd', (guild, user) => {
|
client.on('guildBanAdd', (guild, user) => {
|
||||||
if (user.id != uID) return;
|
if (user.id != uID) return;
|
||||||
stats.set('bans', stats.get('bans') + 1);
|
stats.set('bans', Number(stats.get('bans')) + 1);
|
||||||
updateRole();
|
updateRole();
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('guildMemberUpdate', (oldMember, newMember) => {
|
client.on('guildMemberUpdate', (oldMember, newMember) => {
|
||||||
if (newMember.id != uID) return;
|
if (newMember.id != uID) return;
|
||||||
if (!oldMember.roles.cache.get(muteRoleID) && newMember.roles.cache.get(muteRoleID)) {
|
if (!oldMember.roles.cache.get(muteRoleID) && newMember.roles.cache.get(muteRoleID)) {
|
||||||
stats.set('mutes', stats.get('mutes') + 1);
|
stats.set('mutes', Number(stats.get('mutes')) + 1);
|
||||||
updateRole();
|
updateRole();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('guildMemberAdd', (member) => {
|
client.on('guildMemberAdd', (member) => {
|
||||||
if (member.id == uID) member.roles.add(muteRoleID).catch(e => logger.warn(`Failed to assign role ${muteRoleID}: ${e}`));
|
if (member.id == uID) member.roles.add(statusRoleID).catch(e => logger.warn(`Failed to assign role ${muteRoleID}: ${e}`));
|
||||||
});
|
});
|
||||||
|
|
||||||
let updateRole = () => {
|
let updateRole = () => {
|
||||||
|
|
Loading…
Reference in a new issue