forked from ariffb25/stikerinbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelprem.js
24 lines (19 loc) · 969 Bytes
/
delprem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let fs = require('fs')
let handler = async (m, { conn, text }) => {
const json = JSON.parse(fs.readFileSync('./src/premium.json'))
let who
if (m.isGroup) who = m.mentionedJid[0] ? m.mentionedJid[0] : m.quoted ? m.quoted.sender : text.replace(/[^0-9]/g, '') + '@s.whatsapp.net'
else who = text ? text.replace(/[^0-9]/g, '') + '@s.whatsapp.net' : m.chat
if (json.includes(who)) throw `${conn.getName(who)} belum premium!`
let index = json.findIndex(v => (v.replace(/[^0-9]/g, '') + '@s.whatsapp.net') === (who.replace(/[^0-9]/g, '') + '@s.whatsapp.net'))
json.splice(index, 1)
fs.writeFileSync('./src/premium.json', JSON.stringify(json))
m.reply(`${conn.getName(who)} sekarang bukan premium!`)
delete require.cache[require.resolve('../config')]
require('../config')
}
handler.help = ['delprem [@user]']
handler.tags = ['owner']
handler.command = /^(remove|hapus|-|del)prem$/i
handler.owner = true
module.exports = handler