index.js 850 B

123456789101112131415161718192021222324252627282930
  1. // Version 1.2.2
  2. const Command = require('command')
  3. module.exports = function AFKer(dispatch) {
  4. let enabled = true,
  5. afk = false,
  6. afkCheck = null
  7. dispatch.hook('C_PLAYER_LOCATION', 'raw', () => {
  8. clearTimeout(afkCheck)
  9. afk = false
  10. afkCheck = setTimeout(() => {afk = true}, 3600000) // 1 hour
  11. })
  12. dispatch.hook('C_RETURN_TO_LOBBY', 'raw', () => {
  13. if (enabled && afk) return false // Prevents you from being automatically logged out while AFK
  14. })
  15. // ################# //
  16. // ### Chat Hook ### //
  17. // ################# //
  18. const command = Command(dispatch)
  19. command.add('afk', () => {
  20. enabled = !enabled
  21. command.message('[AFKer] ' + (enabled ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'))
  22. console.log('[AFKer] ' + (enabled ? 'enabled' : 'disabled'))
  23. })
  24. }