forked from Lea/obama-bot
bruh
This commit is contained in:
parent
6cb0156106
commit
0af48d3f0b
2
index.js
2
index.js
|
@ -17,7 +17,7 @@ module.exports = {
|
|||
|
||||
// Execute modules in util folder in order
|
||||
async function runModules() {
|
||||
for (const file of ['commandLoader', 'login', 'eventHandler', 'karma']) {
|
||||
for (const file of ['commandLoader', 'login', 'eventHandler', 'karma', 'carloscounter']) {
|
||||
logger.debug(`Running module ${file}`);
|
||||
await require(`./util/${file}`).run();
|
||||
}
|
||||
|
|
45
util/carloscounter.js
Normal file
45
util/carloscounter.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
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);
|
||||
}
|
Loading…
Reference in a new issue