text: const { set } = require("lodash")
  
  let handler = async (m, { conn, usedPrefix, command, args, isOwner, isAdmin, isROwner }) => {
    let isEnable = /true|enable|(turn)?on|1/i.test(command)
    let chat = global.db.data.chats[m.chat]
    let user = global.db.data.users[m.sender]
    let setting = global.db.data.settings[conn.user.jid]
    let type = (args[0] || '').toLowerCase()
    let isAll = false
    let isUser = false
    switch (type) {
      case 'w':
      case 'welcome':
        if (!m.isGroup) {
          if (!isOwner) {
            global.dfail('group', m, conn)
            throw false
          }
        } else if (!(isAdmin || isOwner)) {
          global.dfail('admin', m, conn)
          throw false
        }
        chat.welcome = isEnable
        break
      case 'detect':
        if (!m.isGroup) {
          if (!isOwner) {
            global.dfail('group', m, conn)
            throw false
          }
        } else if (!(isAdmin || isOwner)) {
          global.dfail('admin', m, conn)
          throw false
        }
        chat.detect = isEnable
        break
      case 'download':
        if (m.isGroup) {
          if (!isPrems) {
            global.dfail('premium', m, conn)
            throw false
          }
        } else if (!(isAdmin || isOwner)) {
          global.dfail('admin', m, conn)
          throw false
        }
        chat.download = isEnable
        break
      case 'desc':
        if (!m.isGroup) {
          if (!isOwner) {
            global.dfail('group', m, conn)
            throw false
          }
        } else if (!(isAdmin || isOwner)) {
          global.dfail('admin', m, conn)
          throw false
        }
        chat.descUpdate = isEnable
        break
      case 'del':
      case 'delete':
        if (m.isGroup) {
          if (!(isAdmin || isOwner)) {
            global.dfail('admin', m, conn)
            throw false
          }
        }
        chat.delete = isEnable
        break
      case 'antidelete':
        if (m.isGroup) {
          if (!(isAdmin || isOwner)) {
            global.dfail('admin', m, conn)
            throw false
          }
        }
        chat.delete = !isEnable
        break
      case 'antibadword':
        if (m.isGroup) {
          if (!(isAdmin || isOwner)) {
            global.dfail('admin', m, conn)
            throw false
          }
        }
        chat.antiBadword = isEnable
        break
      case 'autodelvn':
        if (m.isGroup) {
          if (!(isAdmin || isOwner)) {
            global.dfail('admin', m, conn)
            throw false
          }
        }
        chat.autodelvn = isEnable
        break
      case 'document':
        chat.useDocument = isEnable
        break
      case 'publik':
      case 'public':
        isAll = true
        if (!isROwner) {
          global.dfail('rowner', m, conn)
          throw false
        }
        setting.self = !isEnable
        break
      case 'antilink':
      case 'antiurl':
        if (!m.isGroup) {
          if (!isOwner) {
            global.dfail('group', m, conn)
            throw false
          }
        } else if (!(isAdmin || isOwner)) {
          global.dfail('admin', m, conn)
          throw false
        }
        chat.antiLink = isEnable
      case 's':
      case 'stiker':
        if (m.isGroup) {
          if (!(isAdmin || isOwner)) {
            global.dfail('admin', m, conn)
            throw false
          }
        }
        chat.stiker = isEnable
        break
      case 'autolevelup':
      case 'levelup':
        isUser = true
        user.autolevelup = isEnable
        break
      case 'mycontact':
      case 'mycontacts':
      case 'whitelistcontact':
      case 'whitelistcontacts':
      case 'whitelistmycontact':
      case 'whitelistmycontacts':
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        conn.callWhitelistMode = isEnable
        break
      case 'grup':
      case 'group':
      case 'gruponly':
      case 'grouponly':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        setting.group = isEnable
        break
      case 'backup':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        setting.backup = isEnable
        break
      case 'anticall':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        setting.anticall = isEnable
        break
      case 'antitroli':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        setting.antitroli = isEnable
        break
      case 'autoread':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        db.data.chats[m.chat].read = isEnable
        break
      case 'restrict':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        opts['restrict'] = isEnable
        break
      case 'antispam':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        setting.antispam = isEnable
        break
      case 'anon':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        setting.anon = isEnable
        break
      case 'nsfw':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        setting.nsfw = isEnable
        break
      case 'jadibot':
        isAll = true
        if (!isOwner) {
          global.dfail('owner', m, conn)
          throw false
        }
        setting.jadibot = isEnable
        break
      case 'simi':
        if (m.isGroup) {
          if (!(isAdmin || isOwner)) {
            global.dfail('admin', m, conn)
            throw 0
          }
        }
        chat.simi = isEnable
        break
      default:
        if (!/[01]/.test(command)) throw `
  ┌「 *Daftar Opsi* 」${isOwner ? '\n├ anon\n├ antispam\n├ antitroli\n├ autoread\n├ backup\n├ clear\n├ grouponly\n├ jadibot\n├ nsfw\n├ public\n├ mycontact' : ''}
  ├ antilink
  ├ autolevelup
  ├ delete
  ├ detect
  ├ document
  ├ stiker
  ├ simi
  ├ welcome
  └────
  contoh:
  ${usedPrefix}on welcome
  ${usedPrefix}off welcome
  `.trim()
        throw false
    }
    m.reply(`
  *${type}* berhasil di *${isEnable ? 'nyala' : 'mati'}kan* ${isAll ? 'untuk bot ini' : isUser ? '' : 'untuk chat ini'}
  `.trim())
  }
  handler.help = ['on', 'off'].map(v => v + ' <opsi>')
  handler.tags = ['group', 'owner']
  handler.command = /^((en|dis)able|(tru|fals)e|(turn)?o(n|ff)|[01])$/i
  
  handler.owner = true
  
  module.exports = handler
  