File size: 828 Bytes
bb69f9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const { bot, setAfk } = require('../lib/')

bot(
  {
    pattern: 'afk ?(.*)',
    desc: 'away from keyboard',
    type: 'misc',
  },
  async (message, match, ctx) => {
    if (!ctx.isAfk && !match)
      return await message.send(
        '> Example :\n- My owner is AFK last seen before #lastseen\n- When send a message, automatically set status to not AFK.\n- afk off'
      )
    if (!ctx.isAfk) {
      if (match) ctx.reason = match
      ctx.isAfk = true
      const now = Math.round(new Date().getTime() / 1000)
      setAfk(true, match, now, message.participant, message.id)

      return await message.send(match.replace('#lastseen', now))
    }
    if (match === 'off') {
      await message.send('Your not afk anymore.', { quoted: message.data }, 'text', ctx.p)
      setAfk(false, '', 0, '', message.id)
    }
  }
)