Closed adulalhy closed 3 years ago
Taro diconfig makanya
tau, cuma mau ngasih tau aja ke nurutomo biar di fix
emang cuma sementara karena pake global, kalo mau pake json. berikut langkah-langkahnya
premium.json
di folder src (opsi ini bebas, terserah kamu) isinya terserah kamu juga
["62831xxx", "62831xxx"]
config.js
, jangan lupa pindahin fs nya jadi diatas, karena sblmnya sudah diinisiasi dibawah
global.prems = JSON.parse(fs.readFileSync('./src/premium.json'))
addprem.js
let fs = require('fs')
let handler = async (m, { conn, text, isOwner }) => {
if (!isOwner) throw false
const dbprem = 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
else who = text ? text : m.chat
if (dbprem.includes(who)) throw 'Sudah premium!'
dbprem.push(`${who.split('@')[0]}`)
fs.writeFileSync('./src/premium.json', JSON.stringify(dbprem))
conn.reply(m.chat, `Hai, @${who.split('@')[0]}. Kamu sudah premium!`, m, {
contextInfo: {
mentionedJid: [who]
}
})
delete require.cache[require.resolve('../config')]
require('../config')
}
handler.help = ['+prem *@user*']
handler.tags = ['owner']
handler.command = /^(add|tambah|\+)prem$/i
module.exports = handler
delprem.js
let fs = require('fs')
let handler = async (m, { conn, text, isOwner }) => {
if (!isOwner) throw false
const dbprem = 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
else who = text ? text : m.chat
if (dbprem.includes(who)) throw 'Belum premium!'
let index = dbprem.findIndex(v => (v.replace(/[^0-9]/g, '') + '@s.whatsapp.net') === (who.replace(/[^0-9]/g, '') + '@s.whatsapp.net'))
dbprem.splice(index, 1)
fs.writeFileSync('./src/premium.json', JSON.stringify(dbprem))
conn.reply(m.chat, `Hai, @${who.split`@`[0]}. Masa premium kamu sudah berakhir!`, m, {
contextInfo: {
mentionedJid: [who]
}
})
delete require.cache[require.resolve('../config')]
require('../config')
}
handler.help = ['-prem *@user*']
handler.tags = ['owner']
handler.command = /^(remove|hapus|-|del)prem$/i
module.exports = handler
stale issue
Taro diconfig makanya