Status tracking now on all servers
This commit is contained in:
parent
7d963ef680
commit
e8c1c3644d
@ -28,50 +28,62 @@ const statusOnFoun = (bef, aft) => {
|
|||||||
return [bef, aft];
|
return [bef, aft];
|
||||||
};
|
};
|
||||||
|
|
||||||
const hovno = () => {
|
const ziju = () => {
|
||||||
poslatData({ nejsemPoslej: !0 });
|
poslatData({ nejsemPoslej: !0 });
|
||||||
setTimeout(hovno, 60_000);
|
setTimeout(ziju, 60_000);
|
||||||
};
|
};
|
||||||
hovno();
|
|
||||||
|
if (!process.env.IGNORE_PRESENCE) ziju();
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
// Změna rolí podle statusu a odeslání statusu
|
// Změna rolí podle statusu a odeslání statusu
|
||||||
on_presenceUpdate: (bef, aft) => {
|
on_presenceUpdate: (bef, aft) => {
|
||||||
if (aft.guild.id !== '555779161067749446' || process.env.IGNORE_PRESENCE) return;
|
if (process.env.IGNORE_PRESENCE) return;
|
||||||
|
|
||||||
[bef, aft] = statusOnFoun(bef, aft);
|
[bef, aft] = statusOnFoun(bef, aft);
|
||||||
if (bef.status === aft.status) return;
|
if (bef.status === aft.status) return;
|
||||||
|
|
||||||
aft.member.roles.add(role[aft.status]);
|
if (aft.guild.id !== '555779161067749446') {
|
||||||
aft.member.roles.remove(role[bef.status]);
|
aft.member.roles.add(role[aft.status]);
|
||||||
|
aft.member.roles.remove(role[bef.status]);
|
||||||
|
}
|
||||||
|
|
||||||
prepSend([[aft.user, statusy[aft.status]]]);
|
prepSend([[aft.user, statusy[aft.status]]]);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Odeslání statusů při startu bota
|
// Odeslání statusů při startu bota
|
||||||
on_ready: () => {
|
on_ready: () => {
|
||||||
|
if (process.env.IGNORE_PRESENCE) return;
|
||||||
|
|
||||||
const client = module.exports.client;
|
const client = module.exports.client;
|
||||||
const guild = client.guilds.cache.get("555779161067749446");
|
const guildy = client.guilds.cache;
|
||||||
const memberove = guild.members.cache.clone();
|
const memberove = client.users.cache.clone();
|
||||||
const presence = [...guild.presences.cache.values()];
|
const presence = [];
|
||||||
const changes = [];
|
const changes = [];
|
||||||
|
|
||||||
|
guildy.each(guilda => {
|
||||||
|
guilda.presences.cache.each(pres => {
|
||||||
|
if (!presence.filter(prs => prs.userID === pres.userID).length) presence.push(pres);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
presence.forEach(presenc => {
|
presence.forEach(presenc => {
|
||||||
const status = statusOnFoun(null, presenc)[1].status;
|
const status = statusOnFoun(null, presenc)[1].status;
|
||||||
changes.push([memberove.get(presenc.userID).user, statusy[status]]);
|
changes.push([memberove.get(presenc.userID), statusy[status]]);
|
||||||
memberove.delete(presenc.userID);
|
memberove.delete(presenc.userID);
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const [_, value] of memberove) {
|
memberove.each(member => {
|
||||||
changes.push([value.user, 0]);
|
changes.push([member, 0]);
|
||||||
}
|
});
|
||||||
|
|
||||||
prepSend(changes);
|
prepSend(changes);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Odeslání statusu při změně jména nebo profilovky
|
// Odeslání statusu při změně jména nebo profilovky
|
||||||
on_userUpdate: (_, aft) => {
|
on_userUpdate: (_, aft) => {
|
||||||
prepSend([[aft, statusy[statusOnFoun(null, aft.presence)[1].status]]]);
|
if (!process.env.IGNORE_PRESENCE)
|
||||||
|
prepSend([[aft, statusy[statusOnFoun(null, aft.presence)[1].status]]]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user