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];
|
||||
};
|
||||
|
||||
const hovno = () => {
|
||||
const ziju = () => {
|
||||
poslatData({ nejsemPoslej: !0 });
|
||||
setTimeout(hovno, 60_000);
|
||||
setTimeout(ziju, 60_000);
|
||||
};
|
||||
hovno();
|
||||
|
||||
if (!process.env.IGNORE_PRESENCE) ziju();
|
||||
|
||||
module.exports = {
|
||||
|
||||
// Změna rolí podle statusu a odeslání statusu
|
||||
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);
|
||||
if (bef.status === aft.status) return;
|
||||
|
||||
if (aft.guild.id !== '555779161067749446') {
|
||||
aft.member.roles.add(role[aft.status]);
|
||||
aft.member.roles.remove(role[bef.status]);
|
||||
}
|
||||
|
||||
prepSend([[aft.user, statusy[aft.status]]]);
|
||||
},
|
||||
|
||||
// Odeslání statusů při startu bota
|
||||
on_ready: () => {
|
||||
if (process.env.IGNORE_PRESENCE) return;
|
||||
|
||||
const client = module.exports.client;
|
||||
const guild = client.guilds.cache.get("555779161067749446");
|
||||
const memberove = guild.members.cache.clone();
|
||||
const presence = [...guild.presences.cache.values()];
|
||||
const guildy = client.guilds.cache;
|
||||
const memberove = client.users.cache.clone();
|
||||
const presence = [];
|
||||
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 => {
|
||||
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);
|
||||
});
|
||||
|
||||
for (const [_, value] of memberove) {
|
||||
changes.push([value.user, 0]);
|
||||
}
|
||||
memberove.each(member => {
|
||||
changes.push([member, 0]);
|
||||
});
|
||||
|
||||
prepSend(changes);
|
||||
},
|
||||
|
||||
// Odeslání statusu při změně jména nebo profilovky
|
||||
on_userUpdate: (_, aft) => {
|
||||
if (!process.env.IGNORE_PRESENCE)
|
||||
prepSend([[aft, statusy[statusOnFoun(null, aft.presence)[1].status]]]);
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user