diff --git a/app.js b/app.js index 01f44d5..47aaa01 100644 --- a/app.js +++ b/app.js @@ -5,7 +5,7 @@ const client = new Client(); dotenv.config(); const prefix = process.env.PREFIX || 'more'; -const role = {online: '684443816383610916', idle: '684444083065978941', dnd: '684444020558135399', offline: '684443903759614049'}; +const role = {online: '684443816383610916', idle: '684444083065978941', dnd: '684444020558135399', offline: '684443903759614049', onlinephone: '777989420728975390'}; const akce = {hraj: 'PLAYING', sleduj: 'WATCHING', poslouchej: 'LISTENING', soutez: 'COMPETING', soutěž: 'COMPETING', nedelej: '', nedělej: ''}; const spostece = ['mares', 'mareš', 'purfie', 'denim', '<@!639142938965704745>']; const emouty = ['purfiek3:616026189269696512', 'purfiek3:616026189269696512', 'purfiek3:616026189269696512', 'purfieUchyl:576487602203525138', 'bafW:574646319696576532', 'purfiek4:616026180889477258']; @@ -285,13 +285,12 @@ client.on('message', mes => { client.on('presenceUpdate', (bef, aft) => { if (aft.guild.id !== '555779161067749446') return; - let Return = false; - try { - if (bef.status === aft.status) Return = true; - } catch { - bef = {status: 'offline'}; - } - if (Return) return; + + if (!bef) bef = {status: 'offline', clientStatus: {}}; + if (bef.clientStatus.mobile === 'online' && bef.clientStatus.desktop !== 'online') bef.status = 'onlinephone'; + if (aft.clientStatus.mobile === 'online' && aft.clientStatus.desktop !== 'online') aft.status = 'onlinephone'; + if (bef.status === aft.status) return; + aft.member.roles.add(role[aft.status]); aft.member.roles.remove(role[bef.status]); console.log(`${aft.user.username} změnil status z ${bef.status} na ${aft.status}`);