diff --git a/handler.js b/handler.js index 9823ab5a..81aa79eb 100644 --- a/handler.js +++ b/handler.js @@ -39,6 +39,8 @@ module.exports = { if (!isNumber(user.level)) user.level = 1 if (!isNumber(user.money)) user.money = 0 if (!isNumber(user.bank)) user.bank = 0 + if (!isNumber(user.premiumDate)) user.premiumDate = 0 + if (!'premium' in user) user.premium = false if (!isNumber(user.banklimit)) user.banklimit = 10000 if (!isNumber(user.banknote)) user.banknote = 0 if (!isNumber(user.lastclaim)) user.lastclaim = 0 @@ -48,6 +50,7 @@ module.exports = { if (!isNumber(user.age)) user.age = -1 if (!isNumber(user.regTime)) user.regTime = -1 } + if (!isNumber(user.lastseen)) user.lastseen = 0 if (!isNumber(user.afk)) user.afk = -1 if (!('afkReason' in user)) user.afkReason = '' if (!('banned' in user)) user.banned = false diff --git a/plugins/_expired.js b/plugins/_expired.js index 56f3d9d3..5e5e043c 100644 --- a/plugins/_expired.js +++ b/plugins/_expired.js @@ -3,7 +3,7 @@ handler.before = async function (m) { if (m.isGroup && db.data.chats[m.chat].expired != 0) { if (new Date() * 1 >= db.data.chats[m.chat].expired) { - this.reply(m.chat, `waktunya *${this.user.name}* untuk meninggalkan grup`, null).then(() => { + this.reply(m.chat, `Trial atau waktu sewa anda sudah habis\nwaktunya *${this.user.name}* untuk meninggalkan grup`, null).then(() => { this.sendContact(m.chat, owner[0], this.getName(owner[0] + '@s.whatsapp.net'), m).then(() => { this.groupLeave(m.chat).then(() => { db.data.chats[m.chat].expired = 0 diff --git a/plugins/monthly.js b/plugins/monthly.js index 7e6cb1f2..35fca6eb 100644 --- a/plugins/monthly.js +++ b/plugins/monthly.js @@ -1,7 +1,7 @@ let { MessageType } = require('@adiwajshing/baileys') let handler = async (m, { conn }) => { - let user = global.DATABASE._data.users[m.sender] + let user = global.db.data.users[m.sender] let _timers = (2592000000 - (new Date - user.lastmonthly)) let timers = clockString(_timers) if (new Date - user.lastmonthly > 2592000000) { diff --git a/plugins/sider.js b/plugins/sider.js new file mode 100644 index 00000000..f8184c51 --- /dev/null +++ b/plugins/sider.js @@ -0,0 +1,57 @@ +let { MessageType, Presence } = require('@adiwajshing/baileys') +let handler = async (m, { conn, text, participants }) => { + await conn.updatePresence(m.chat, Presence.composing) + var lama = 86400000 * 7 + let member = participants.map(u => u.jid) + if(!text) { + var pesan = "Harap aktif di grup karena akan ada pembersihan member setiap saat" + } else { + var pesan = text + } + sum = member.length + var total = 0 + var sider = [] + for(let i = 0; i < sum; i++) { + let users = m.isGroup ? participants.find(u => u.jid == member[i]) : {} + if((typeof global.DATABASE.data.users[member[i]] == 'undefined' || new Date() * 1 - global.DATABASE.data.users[member[i]].lastseen > lama) && !users.isAdmin && !users.isSuperAdmin) { + if (typeof global.DATABASE.data.users[member[i]] !== 'undefined'){ + if(global.DATABASE.data.users[member[i]].whitelist == false){ + total++ + sider.push(member[i]) + } + }else { + total++ + sider.push(member[i]) + } + } + } + if(total == 0) return conn.reply(m.chat, `*Digrup ini tidak terdapat sider.*`, m) + conn.reply(m.chat, `*${total}/${sum}* anggota grup *${conn.getName(m.chat)}* adalah sider dengan alasan :\n1. Tidak aktif selama lebih dari 7 hari\n2. Baru join tetapi tidak pernah nimbrung\n\n_“${pesan}”_\n\n*LIST SIDER :*\n${sider.map(v => ' ○ @' + v.replace(/@.+/, '' + typeof global.DATABASE.data.users[v] == "undefined" ? ' join doang' : ' off ' + msToDate(new Date()*1 - global.DATABASE.data.users[v].lastseen))).join('\n')}`, m,{ contextInfo: { mentionedJid: sider } }) +} +handler.help = ['sider'] +handler.tags = ['group', 'group admin'] +handler.command = /^(sider)$/i +handler.group = true +handler.botAdmin = true +handler.fail = null +module.exports = handler + +const more = String.fromCharCode(8206) +const readMore = more.repeat(4001) + +function msToDate(ms) { + temp = ms + days = Math.floor(ms / (24*60*60*1000)); + daysms = ms % (24*60*60*1000); + hours = Math.floor((daysms)/(60*60*1000)); + hoursms = ms % (60*60*1000); + minutes = Math.floor((hoursms)/(60*1000)); + minutesms = ms % (60*1000); + sec = Math.floor((minutesms)/(1000)); + if (days == 0 && hours == 0 && minutes == 0){ + return "Baru Saja" + }else { + return days+"H "+hours+"J"; + } + // +minutes+":"+sec; +} \ No newline at end of file diff --git a/plugins/trial.js b/plugins/trial.js index c0268281..18d49104 100644 --- a/plugins/trial.js +++ b/plugins/trial.js @@ -4,14 +4,14 @@ let handler = async (m, { conn, text, usedPrefix }) => { let [_, code] = text.match(linkRegex) || [] if (!code) throw 'Link Salah' let res = await conn.acceptInvite(code) - m.reply(`Berhasil join grup ${res.gid}`).then(() => { + m.reply(`Berhasil join grup ${res.gid}\nTrial 5 hari di mulai`).then(() => { var jumlahHari = 86400000 * 0.5 var now = new Date() * 1 if (now < global.db.data.chats[res.gid].expired) global.db.data.chats[res.gid].expired += jumlahHari else global.db.data.chats[res.gid].expired = now + jumlahHari }) await conn.sendButton(res.gid, ` -*${conn.user.name}* adalah bot whatsapp yang dibangun dengan Nodejs, *${conn.user.name}* diundang oleh @${m.sender.split`@`[0]} +*${conn.user.name}* adalah bot whatsapp yang dibangun dengan Nodejs,\nTrial 5 hari di mulai\n*${conn.user.name}* diundang oleh @${m.sender.split`@`[0]} ketik *${usedPrefix}menu* untuk melihat daftar perintah`.trim(), '© Raiden', 'Menu', `${usedPrefix}?`, { contextInfo: { mentionedJid: [m.sender] } }) } diff --git a/plugins/weekly.js b/plugins/weekly.js index d7ad4b1d..efcc5fcd 100644 --- a/plugins/weekly.js +++ b/plugins/weekly.js @@ -1,7 +1,7 @@ let { MessageType } = require('@adiwajshing/baileys') let handler = async (m, { conn }) => { - let user = global.DATABASE._data.users[m.sender] + let user = global.db.data.users[m.sender] let _timers = (604800000 - (new Date - user.lastweekly)) let timers = clockString(_timers) if (new Date - user.lastweekly > 604800000) {