User: apakah kode ini sudah benar, jawab ya jika sudah benar, jawab belum jika masi ada yang salah kodenya = import {
	smsg
} from './lib/simple.js'
import {
	format
} from 'util'
import {
	fileURLToPath
} from 'url'
import path, {
	join
} from 'path'
import {
	unwatchFile,
	watchFile
} from 'fs'
import chalk from 'chalk'
import fs from 'fs'
import fetch from 'node-fetch'
import moment from 'moment-timezone'
const printMessage = (await import('./lib/print.js')).default
/**
 * @type {import('baileys')}
 */
const {
	proto
} = (await import('baileys')).default
const isNumber = x => typeof x === 'number' && !isNaN(x)
const delay = ms => isNumber(ms) && new Promise(resolve => setTimeout(function() {
	clearTimeout(this)
	resolve()
}, ms))

/**
 * Handle messages upsert
 * @param {import('baileys').BaileysEventMap<unknown>['messages.upsert']} groupsUpdate
 */
export async function handler(chatUpdate) {
	this.msgqueque = this.msgqueque || []
	if (!chatUpdate)
		return
	this.pushMessage(chatUpdate.messages).catch(console.error)
	let m = chatUpdate.messages[chatUpdate.messages.length - 1]
	if (!m)
		return
	if (global.db.data == null)
		await global.loadDatabase()
	try {
		m = smsg(this, m) || m
		if (!m)
			return
		m.exp = 0
		m.energy = false
		try {
			// TODO: use loop to insert data instead of this
			let user = global.db.data.users[m.sender]
			if (typeof user !== 'object')
				global.db.data.users[m.sender] = {}
			if (user) {
			    if (!isNumber(user.energy)) user.energy = 100
			    if (!isNumber(user.balance)) user.balance = 0
			    if (!isNumber(user.exp)) user.exp = 0
			    if (!isNumber(user.level)) user.level = 0
			    if (!("role" in user)) user.role = "Beginner"
			    
			    if (!isNumber(user.afk)) user.afk = -1
			    if (!("afkReason" in user)) user.afkReason = ""
			    
			    if (!("banned" in user)) user.banned = false
			    if (!("bannedReason" in user)) user.bannedReason = ""
			    if (!isNumber(user.bannedLast)) user.bannedLast = 0
			    if (!isNumber(user.lastBanned)) user.lastBanned = 0
			    
			    if (!user.registered) {
					if (!("name" in user)) user.name = m.name
					if (!("sn" in user)) user.sn = ""
					if (!isNumber(user.age)) user.age = -1
					if (!("premium" in user)) user.premium = false
					if (!isNumber(user.premiumTime)) user.premiumTime = 0
					if (!isNumber(user.premiumDate)) user.premiumDate = -1
					if (!isNumber(user.regTime)) user.regTime = -1
				}
				if (!("registered" in user)) user.registered = false
				
				if (!("title" in user)) user.title = ""
			} else
				global.db.data.users[m.sender] = {
                    energy: 100,
                    balance: 0,
                    exp: 0,
                    level: 0,
                    role: "Beginner",
                    
                    afk: -1 ,
                    afkReason: "",
                    
                    banned: false, 
                    bannedReason: "",
                    bannedLast: 0,
                    lastBanned: 0,
                    
                    name: m.name,
                    sn: "",
                    age: -1,
                    premium: false, 
                    premiumTime: 0,
                    premiumDate: -1,
                    regTime: -1,
                    registered: false, 
                    
                    title: "",
				}
			let chat = global.db.data.chats[m.chat]
			if (typeof chat !== 'object')
				global.db.data.chats[m.chat] = {}
			if (chat) {
				if (!('isBanned' in chat))
					chat.isBanned = false
				if (!('welcome' in chat))
					chat.welcome = false
				if (!('goodbye' in chat)) 
				    chat.goodbye = false
				if (!('detect' in chat))
					chat.detect = false
				if (!('sWelcome' in chat))
					chat.sWelcome = ''
				if (!('sBye' in chat))
					chat.sBye = ''
				if (!('sPromote' in chat))
					chat.sPromote = ''
				if (!('sDemote' in chat))
					chat.sDemote = ''
				if (!('listStr' in chat))
					chat.listStr = {}
				if (!('delete' in chat))
					chat.delete = true
				if (!isNumber(chat.expired))
					chat.expired = 0
			} else
				global.db.data.chats[m.chat] = {
					isBanned: false,
					welcome: false,
					goodbye: false, 
					detect: false,
					sWelcome: '',
					sBye: '',
					sPromote: '',
					sDemote: '',
					listStr: {},
					delete: true,
					expired: 0,
				}
			let settings = global.db.data.settings[this.user.jid]
			if (typeof settings !== 'object') global.db.data.settings[this.user.jid] = {}
			if (settings) {
				if (!('self' in settings)) settings.self = false
				if (!('autoread' in settings)) settings.autoread = true
				if (!('anticall' in settings)) settings.anticall = true
				if (!('pconlyprem' in settings)) settings.pconlyprem = false
				if (!('maintenance' in settings)) settings.maintenance = false
			} else global.db.data.settings[this.user.jid] = {
				self: false,
				autoread: true,
				anticall: true,
				pconlyprem: false,
				maintenance: false, 
			}
		} catch (e) {
			console.error(e)
		}

		if (opts['nyimak'])
			return
		if (!m.fromMe && opts['self'])
			return
		if (opts['pconly'] && m.chat.endsWith('g.us'))
			return
		if (opts['gconly'] && !m.chat.endsWith('g.us'))
			return
		if (opts['swonly'] && m.chat !== 'status@broadcast')
			return
		if (typeof m.text !== 'string')
			m.text = ''

		//const isROwner = [global.conn.user.jid, ...global.owner].map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender)
		const isROwner = [global.conn.user.jid, ...global.owner, ...global.hsb].map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender)
		const isOwner = isROwner
		const isMods = isOwner || m.fromMe || global.mods.map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender)
		const isPrems = isROwner || isMods || (db.data.users[m.sender].premiumTime > 0 || db.data.users[m.sender].premium)

		if (opts['queque'] && m.text && !(isMods || isPrems)) {
			let queque = this.msgqueque,
				time = 1000 * 5
			const previousID = queque[queque.length - 1]
			queque.push(m.id || m.key.id)
			setInterval(async function() {
				if (queque.indexOf(previousID) === -1) clearInterval(this)
				await delay(time)
			}, time)
		}

		//if (m.id.startsWith('BAE5') && m.id.length === 16 || m.isBaileys && m.fromMe) return
		if (m.id.startsWith('3EB0') || (m.id.startsWith('BAE5') && m.id.length === 16) || m.isBaileys && m.fromMe) return;
		m.exp += Math.ceil(Math.random() * 10)

		let usedPrefix
		let _user = global.db.data && global.db.data.users && global.db.data.users[m.sender]

		const groupMetadata = (m.isGroup ? ((conn.chats[m.chat] || {}).metadata || await this.groupMetadata(m.chat).catch(_ => null)) : {}) || {}
		const participants = (m.isGroup ? groupMetadata.participants : []) || []
		const user = (m.isGroup ? participants.find(u => conn.decodeJid(u.id) === m.sender) : {}) || {} // User Data
		const bot = (m.isGroup ? participants.find(u => conn.decodeJid(u.id) == this.user.jid) : {}) || {} // Your Data
		const isRAdmin = user?.admin == 'superadmin' || false
		const isAdmin = isRAdmin || user?.admin == 'admin' || false // Is User Admin?
		const isBotAdmin = bot?.admin || false // Are you Admin?

		const ___dirname = path.join(path.dirname(fileURLToPath(import.meta.url)), './plugins')
		for (let name in global.plugins) {
			let plugin = global.plugins[name]
			if (!plugin)
				continue
			if (plugin.disabled)
				continue
			const __filename = join(___dirname, name)
			if (typeof plugin.all === 'function') {
				try {
					await plugin.all.call(this, m, {
						chatUpdate,
						__dirname: ___dirname,
						__filename
					})
				} catch (e) {
					// if (typeof e === 'string') continue
					console.error(e)
					for (let [jid] of global.owner.filter(([number, _, isDeveloper]) => isDeveloper && number)) {
						let data = (await conn.onWhatsApp(jid))[0] || {}
						if (data.exists)
							m.reply(`*Plugin:* ${name}\n*Sender:* ${m.sender}\n*Chat:* ${m.chat}\n*Command:* ${m.text}\n\n\`\`\`${format(e)}\`\`\``.trim(), data.jid)
					}
				}
			}
			if (!opts['restrict'])
				if (plugin.tags && plugin.tags.includes('admin')) {
					// global.dfail('restrict', m, this)
					continue
				}
			const str2Regex = str => str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
			let _prefix = plugin.customPrefix ? plugin.customPrefix : conn.prefix ? conn.prefix : global.prefix
			let match = (_prefix instanceof RegExp ? // RegExp Mode?
				[
					[_prefix.exec(m.text), _prefix]
				] :
				Array.isArray(_prefix) ? // Array?
				_prefix.map(p => {
					let re = p instanceof RegExp ? // RegExp in Array?
						p :
						new RegExp(str2Regex(p))
					return [re.exec(m.text), re]
				}) :
				typeof _prefix === 'string' ? // String?
				[
					[new RegExp(str2Regex(_prefix)).exec(m.text), new RegExp(str2Regex(_prefix))]
				] : [
					[
						[], new RegExp
					]
				]
			).find(p => p[1])
			if (typeof plugin.before === 'function') {
				if (await plugin.before.call(this, m, {
						match,
						conn: this,
						participants,
						groupMetadata,
						user,
						bot,
						isROwner,
						isOwner,
						isRAdmin,
						isAdmin,
						isBotAdmin,
						isPrems,
						chatUpdate,
						__dirname: ___dirname,
						__filename
					}))
					continue
			}
			if (typeof plugin !== 'function')
				continue
			if ((usedPrefix = (match[0] || '')[0])) {
				let noPrefix = m.text.replace(usedPrefix, '')
				let [command, ...args] = noPrefix.trim().split` `.filter(v => v)
				args = args || []
				let _args = noPrefix.trim().split` `.slice(1)
				let text = _args.join` `
				command = (command || '').toLowerCase()
				let fail = plugin.fail || global.dfail // When failed
				let isAccept = plugin.command instanceof RegExp ? // RegExp Mode?
					plugin.command.test(command) :
					Array.isArray(plugin.command) ? // Array?
					plugin.command.some(cmd => cmd instanceof RegExp ? // RegExp in Array?
						cmd.test(command) : cmd === command) : typeof plugin.command === 'string' ? // String?
					plugin.command === command : false

				if (!isAccept)
					continue
				m.plugin = name
				if (m.chat in global.db.data.chats || m.sender in global.db.data.users) {
					let chat = global.db.data.chats[m.chat]
					let user = global.db.data.users[m.sender]
					let ban = db.data.banned[m.sender]
					if (typeof ban !== 'undefined' && ban.status)
						return
					if (name != 'owner-unbanchat.js' && name != 'owner-exec.js' && name != 'owner-exec2.js' && name != 'tool-delete.js' && name != 'mode-bot.js' && chat?.isBanned)
						return
					if (name != 'owner-unbanuser.js' && name != 'owner-exec.js' && name != 'owner-exec2.js' && name != 'info-cekbanned.js' && name != 'cek-banned.js' && user?.banned)
						return
					if (global.db.data.settings.pconlyprem && !user.premium && !m.isGroup)
					    return
					if (global.db.data.settings.maintenance && !isROwner && !isOwner) 
					    return
				}
				if (plugin.rowner && plugin.owner && !(isROwner || isOwner)) {
					fail('owner', m, this)
					continue
				}
				if (plugin.rowner && !isROwner) {
					fail('rowner', m, this)
					continue
				}
				if (plugin.owner && !isOwner) {
					fail('owner', m, this)
					continue
				}
				if (plugin.mods && !isMods) {
					fail('mods', m, this)
					continue
				}
				if (plugin.premium && !isPrems) {
					fail('premium', m, this)
					continue
				}
				if (plugin.group && !m.isGroup) {
					fail('group', m, this)
					continue
				} else if (plugin.botAdmin && !isBotAdmin) {
					fail('botAdmin', m, this)
					continue
				} else if (plugin.admin && !isAdmin) {
					fail('admin', m, this)
					continue
				}
				if (plugin.private && m.isGroup) {
					fail('private', m, this)
					continue
				}
				if (plugin.register && !_user.registered) {
					fail('unreg', m, this)
					continue
				}
				if (plugin.onlyprem && !m.isGroup && !isPrems) {
					fail('onlyprem', m, this)
					continue
				}
				m.isCommand = true
				let xp = 'exp' in plugin ? parseInt(plugin.exp) : 17 // XP Earning per command
				if (xp > 200)
					m.reply('Ngecit -_-') // Hehehe
				else
					m.exp += xp
				if (!isPrems && plugin.energy && _user.energy < plugin.energy * 1) {
					m.reply(global.pricelist);
					continue
				}
				if (plugin.level > _user.level) {
					this.reply(m.chat, `[💬] Mohon maaf level yang di perlukan untuk menggunakan fitur ini ${plugin.level}\n*Level mu:* ${_user.level} 📊`, m)
					continue
				}
				if (plugin.age > _user.age) {
					this.reply(m.chat, `[💬] Umurmu harus diatas ${plugin.age} Tahun untuk menggunakan fitur ini...`, m)
					continue
				}
				let isCmddd = /^[°•π÷×¶∆£¢€¥®™+✓_=|~!?@#$%^&.©^]/gi.test(m.text)
				if (isCmddd && !isPrems && !m.isGroup && !conn.werewolf && !conn.orderkouta) {
//			       this.sendMessage(m.chat, { text: `⚠️ Menggunakan bot dalam obrolan pribadi hanya untuk pengguna premium.\n\n*PREMIUM USER PRICE LIST*\n\n*3 Day premium*\n- OrderID: 3\n- Price: Rp. 5.000 IDR\n\n*7 Day premium*\n- OrderID: 7\n- Price: Rp. 10.000 IDR\n\n*30 Day premium*\n- OrderID: 30\n- Price: Rp. 15.000 IDR\n\n*60 Day premium*\n- OrderID: 60\n- Price: Rp. 30.000 IDR\n\n*90 Day premium*\n- OrderID: 90\n- Price: Rp. 40.000 IDR\n\n*365 Day premium*\n- OrderID: 365\n- Price: Rp. 115.000 IDR\n\nTolong ikuti cara pembayaran ini.\n\nSilahkan tulis seperti ini : *.order <OrderID>*\nContoh: *.order 30*\n\nJika anda terlalu bodoh. anda bisa langsung menghubungi nomor owner kami melalui link di bawah ini:\nwa.me/${global.info.nomorown}\n\nThank you for using our bot #MaximusStore`, contextInfo: { mentionedJid: [m.sender], externalAdReply: { title: '', body: '', thumbnailUrl: "https://telegra.ph/file/0b32e0a0bb3b81fef9838.jpg", sourceUrl: "", mediaType: 1, renderLargerThumbnail: true }} })
			    	continue
				}
				let extra = {
					match,
					usedPrefix,
					noPrefix,
					_args,
					args,
					command,
					text,
					conn: this,
					participants,
					groupMetadata,
					user,
					bot,
					isROwner,
					isOwner,
					isRAdmin,
					isAdmin,
					isBotAdmin,
					isPrems,
					chatUpdate,
					__dirname: ___dirname,
					__filename
				}
				try {
					await plugin.call(this, m, extra)
					if (!isPrems)
						m.energy = m.energy || plugin.energy || false
				} catch (e) {
					// Error occured
					m.error = e
					console.error(e)
					if (e) {
						let text = format(e)
						for (let key of Object.values(global.APIKeys))
							text = text.replace(new RegExp(key, 'g'), '#HIDDEN#')
						if (e.name)
							for (let [jid] of global.owner.filter(([number, _, isDeveloper]) => isDeveloper && number)) {
								let data = (await conn.onWhatsApp(jid))[0] || {}
								if (data.exists)
									m.reply(`*🗂️ Plugin:* ${m.plugin}\n*👤 Sender:* ${m.sender}\n*💬 Chat:* ${m.chat}\n*💻 Command:* ${usedPrefix}${command} ${args.join(' ')}\n📄 *Error Logs:*\n\n\`\`\`${text}\`\`\``.trim(), data.jid)
							}
						m.reply(text)
					}
				} finally {
					// m.reply(util.format(_user))
					if (typeof plugin.after === 'function') {
						try {
							await plugin.after.call(this, m, extra)
						} catch (e) {
							console.error(e)
						}
					}
					//if (m.energy)
					   //await m.reply(`⚡ Energi -` + m.energy)
				}
				break
			}
		}
	} catch (e) {
		console.error(e)
	} finally {
		if (opts['queque'] && m.text) {
			const quequeIndex = this.msgqueque.indexOf(m.id || m.key.id)
			if (quequeIndex !== -1)
				this.msgqueque.splice(quequeIndex, 1)
		}
		//console.log(global.db.data.users[m.sender])
		let user,
			stats = global.db.data.stats
		if (m) {
			if (m.sender && (user = global.db.data.users[m.sender])) {
				user.exp += m.exp
				user.energy -= m.energy * 1
			}

			let stat
			if (m.plugin) {
				let now = +new Date
				if (m.plugin in stats) {
					stat = stats[m.plugin]
					if (!isNumber(stat.total))
						stat.total = 1
					if (!isNumber(stat.success))
						stat.success = m.error != null ? 0 : 1
					if (!isNumber(stat.last))
						stat.last = now
					if (!isNumber(stat.lastSuccess))
						stat.lastSuccess = m.error != null ? 0 : now
				} else
					stat = stats[m.plugin] = {
						total: 1,
						success: m.error != null ? 0 : 1,
						last: now,
						lastSuccess: m.error != null ? 0 : now
					}
				stat.total += 1
				stat.last = now
				if (m.error == null) {
					stat.success += 1
					stat.lastSuccess = now
				}
			}
		}

		try {
			if (!opts['noprint']) await printMessage(m, this)
		} catch (e) {
			console.log(m, m.quoted, e)
		}
		if (global.db.data.settings[this.user.jid].autoread)
			await this.readMessages([m.key]).catch(() => {})

		if (global.db.data.settings[this.user.jid].composing)
			await this.sendPresenceUpdate('composing', m.chat).catch(() => {})
	}
}

/**
 * Handle groups participants update
 * @param {import('baileys').BaileysEventMap<unknown>['group-participants.update']} groupsUpdate
 */
export async function participantsUpdate({
	id,
	participants,
	action
}) {
	if (opts['self'])
		return
	if (this.isInit)
		return
	let chat = global.db.data.chats[id] || {}
	let text = ''
	switch (action) {
		case 'add':
			if (chat.welcome) {
				let groupMetadata = await this.groupMetadata(id) || (conn.chats[id] || {}).metadata
				for (let user of participants) {
					let pp = fs.readFileSync('./src/avatar_contact.png')
					try {
						pp = await this.profilePictureUrl(user, 'image')
					} catch (e) {} finally {
						text = (action === 'add' ? (chat.sWelcome || this.welcome || conn.welcome || 'Welcome, @user!').replace('@subject', await this.getName(id)).replace('@desc', groupMetadata.desc ? String.fromCharCode(8206).repeat(4001) + groupMetadata.desc : '') :
							(chat.sBye || this.bye || conn.bye || 'Bye, @user!')).replace('@user', '@' + user.split('@')[0])
						let wel = 'https://telegra.ph/file/6922e4375c183c8d1cfcb.jpg'
						
						await this.sendMessage(id, { text: text, contextInfo: { mentionedJid: [user] }}, { quoted: null })

					}
				}
			}
			break
		case 'remove':
			if (chat.goodbye) {
				let groupMetadata = await this.groupMetadata(id) || (conn.chats[id] || {}).metadata
				for (let user of participants) {
					let pp = fs.readFileSync('./src/avatar_contact.png')
					try {
						pp = await this.profilePictureUrl(user, 'image')
					} catch (e) {} finally {
						text = (action === 'add' ? (chat.sWelcome || this.welcome || conn.welcome || 'Welcome, @user!').replace('@subject', await this.getName(id)).replace('@desc', groupMetadata.desc ? String.fromCharCode(8206).repeat(4001) + groupMetadata.desc : '') :
							(chat.sBye || this.bye || conn.bye || 'Bye, @user!')).replace('@user', '@' + user.split('@')[0])
						let lea = 'https://telegra.ph/file/8c7792e78ed015a7d0a59.jpg'
						
						await this.sendMessage(id, { text: text, contextInfo: { mentionedJid: [user] }}, { quoted: null })

					}
				}
			}
			break
		case 'promote':
			text = (chat.sPromote || this.spromote || conn.spromote || '@user ```is now Admin```')
		case 'demote':
			if (!text)
				text = (chat.sDemote || this.sdemote || conn.sdemote || '@user ```is no longer Admin```')
			text = text.replace('@user', '@' + participants[0].split('@')[0])
			if (chat.detect)
				this.sendMessage(id, {
					text,
					mentions: this.parseMention(text)
				})
			break
	}
}
/**
 * Handle groups update
 * @param {import('baileys').BaileysEventMap<unknown>['groups.update']} groupsUpdate
 */
export async function groupsUpdate(groupsUpdate) {
	if (opts['self'])
		return
	for (const groupUpdate of groupsUpdate) {
		const id = groupUpdate.id
		if (!id) continue
		let chats = global.db.data.chats[id],
			text = ''
		if (!chats?.detect) continue
		if (groupUpdate.desc) text = (chats.sDesc || this.sDesc || conn.sDesc || '```Description has been changed to```\n@desc').replace('@desc', groupUpdate.desc)
		if (groupUpdate.subject) text = (chats.sSubject || this.sSubject || conn.sSubject || '```Subject has been changed to```\n@subject').replace('@subject', groupUpdate.subject)
		if (groupUpdate.icon) text = (chats.sIcon || this.sIcon || conn.sIcon || '```Icon has been changed to```').replace('@icon', groupUpdate.icon)
		if (groupUpdate.revoke) text = (chats.sRevoke || this.sRevoke || conn.sRevoke || '```Group link has been changed to```\n@revoke').replace('@revoke', groupUpdate.revoke)
		if (!text) continue
		await this.sendMessage(id, {
			text,
			mentions: this.parseMention(text)
		})
	}
}

export async function deleteUpdate(message) {
	try {
		const {
			fromMe,
			id,
			participant
		} = message
		if (fromMe)
			return
		let msg = this.serializeM(this.loadMessage(id))
		if (!msg)
			return
		let chat = global.db.data.chats[msg.chat] || {}
		if (chat.delete)
			return
		await this.reply(msg.chat, `
⧻Terdeteksi @${participant.split`@`[0]} telah menghapus pesan
Untuk mematikan fitur ini, Admin harus mengetik 
*.disable antidelete*
`.trim(), msg, {
			mentions: [participant]
		})
		this.copyNForward(msg.chat, msg).catch(e => console.log(e, msg))
	} catch (e) {
		console.error(e)
	}
}

global.dfail = (type, m, conn) => {
	let msg = {
		rowner: 'Perintah ini hanya untuk *R-OWNER*',
		owner: 'Perintah ini hanya untuk *OWNER*',
		mods: 'Perintah ini hanya untuk *MODS*',
		premium: 'Perintah ini hanya untuk *USER PREMIUM*',
		group: 'Perintah ini hanya untuk *GROUPS*',
		private: 'Perintah ini hanya untuk *PRIVATE MESSAGE*',
		admin: 'Perintah ini hanya untuk *ADMIN*',
		botAdmin: 'Perintah ini hanya untuk *BOT-ADMINS*',
		onlyprem: 'Perintah ini hanya untuk *USER PREMIUM*',
		nsfw: 'Perintah ini belum diaktifkan di grup ini.\n\n> Aktifkan Fitur Ini Dengan Mengetik *.enable nsfw*',
		rpg: 'Perintah ini belum diaktifkan di grup ini.\n\n> Aktifkan Fitur Ini Dengan Mengetik *.enable rpg*',
		game: 'Perintah Ini Belum Diaktifkan Di Grup Ini.\n\n> Aktifkan Fitur Ini Dengan Mengetik *.enable game*',
		restrict: '*FITUR DIMATIKAN OLEH OWNER*',
		unreg: '*Silakan mendaftar terlebih dahulu dengan mengetik \`#daftar name.age\`*\n\n* *Setelah Anda terdaftar, maka Anda dapat menggunakan perintah ini.*\n\n*Contoh pendaftaran:*\n\n\`#daftar gon.18\`\n\n*Catatan:*\n- Gunakan nama asli dan umur yang benar\n- Jika sudah mendaftar maka kamu tidak perlu mendaftar lagi'
	} [type]

	if (msg) return conn.sendMessage(m.chat, { text: `*Hi @${m.sender.split('@')[0]} 👋🏻*\n\n` + msg, contextInfo: { mentionedJid: [m.sender] }})
}

let file = global.__filename(import.meta.url, true)
watchFile(file, async () => {
	unwatchFile(file)
	console.log(chalk.redBright("Update 'handler.js'"))
	if (global.reloadHandler) console.log(await global.reloadHandler())
})

function ucapan() {
	const time = moment.tz('Asia/Jakarta').format('HH')
	let res = "Sudah Dini Hari Kok Belum Tidur Kak? ??"
	if (time >= 4) {
		res = "Selamat Pagi"
	}
	if (time >= 10) {
		res = "Selamat Siang"
	}
	if (time >= 15) {
		res = "Selamat Sore"
	}
	if (time >= 18) {
		res = "Selamat Malam"
	}
	return res
}
User: apakah kode ini sudah benar, jawab ya jika sudah benar, jawab belum jika masi ada yang salah kodenya = import {
	smsg
} from './lib/simple.js'
import {
	format
} from 'util'
import {
	fileURLToPath
} from 'url'
import path, {
	join
} from 'path'
import {
	unwatchFile,
	watchFile
} from 'fs'
import chalk from 'chalk'
import fs from 'fs'
import fetch from 'node-fetch'
import moment from 'moment-timezone'
const printMessage = (await import('./lib/print.js')).default
/**
 * @type {import('baileys')}
 */
const {
	proto
} = (await import('baileys')).default
const isNumber = x => typeof x === 'number' && !isNaN(x)
const delay = ms => isNumber(ms) && new Promise(resolve => setTimeout(function() {
	clearTimeout(this)
	resolve()
}, ms))

/**
 * Handle messages upsert
 * @param {import('baileys').BaileysEventMap<unknown>['messages.upsert']} groupsUpdate
 */
export async function handler(chatUpdate) {
	this.msgqueque = this.msgqueque || []
	if (!chatUpdate)
		return
	this.pushMessage(chatUpdate.messages).catch(console.error)
	let m = chatUpdate.messages[chatUpdate.messages.length - 1]
	if (!m)
		return
	if (global.db.data == null)
		await global.loadDatabase()
	try {
		m = smsg(this, m) || m
		if (!m)
			return
		m.exp = 0
		m.energy = false
		try {
			// TODO: use loop to insert data instead of this
			let user = global.db.data.users[m.sender]
			if (typeof user !== 'object')
				global.db.data.users[m.sender] = {}
			if (user) {
			    if (!isNumber(user.energy)) user.energy = 100
			    if (!isNumber(user.balance)) user.balance = 0
			    if (!isNumber(user.exp)) user.exp = 0
			    if (!isNumber(user.level)) user.level = 0
			    if (!("role" in user)) user.role = "Beginner"
			    
			    if (!isNumber(user.afk)) user.afk = -1
			    if (!("afkReason" in user)) user.afkReason = ""
			    
			    if (!("banned" in user)) user.banned = false
			    if (!("bannedReason" in user)) user.bannedReason = ""
			    if (!isNumber(user.bannedLast)) user.bannedLast = 0
			    if (!isNumber(user.lastBanned)) user.lastBanned = 0
			    
			    if (!user.registered) {
					if (!("name" in user)) user.name = m.name
					if (!("sn" in user)) user.sn = ""
					if (!isNumber(user.age)) user.age = -1
					if (!("premium" in user)) user.premium = false
					if (!isNumber(user.premiumTime)) user.premiumTime = 0
					if (!isNumber(user.premiumDate)) user.premiumDate = -1
					if (!isNumber(user.regTime)) user.regTime = -1
				}
				if (!("registered" in user)) user.registered = false
				
				if (!("title" in user)) user.title = ""
			} else
				global.db.data.users[m.sender] = {
                    energy: 100,
                    balance: 0,
                    exp: 0,
                    level: 0,
                    role: "Beginner",
                    
                    afk: -1 ,
                    afkReason: "",
                    
                    banned: false, 
                    bannedReason: "",
                    bannedLast: 0,
                    lastBanned: 0,
                    
                    name: m.name,
                    sn: "",
                    age: -1,
                    premium: false, 
                    premiumTime: 0,
                    premiumDate: -1,
                    regTime: -1,
                    registered: false, 
                    
                    title: "",
				}
			let chat = global.db.data.chats[m.chat]
			if (typeof chat !== 'object')
				global.db.data.chats[m.chat] = {}
			if (chat) {
				if (!('isBanned' in chat))
					chat.isBanned = false
				if (!('welcome' in chat))
					chat.welcome = false
				if (!('goodbye' in chat)) 
				    chat.goodbye = false
				if (!('detect' in chat))
					chat.detect = false
				if (!('sWelcome' in chat))
					chat.sWelcome = ''
				if (!('sBye' in chat))
					chat.sBye = ''
				if (!('sPromote' in chat))
					chat.sPromote = ''
				if (!('sDemote' in chat))
					chat.sDemote = ''
				if (!('listStr' in chat))
					chat.listStr = {}
				if (!('delete' in chat))
					chat.delete = true
				if (!isNumber(chat.expired))
					chat.expired = 0
			} else
				global.db.data.chats[m.chat] = {
					isBanned: false,
					welcome: false,
					goodbye: false, 
					detect: false,
					sWelcome: '',
					sBye: '',
					sPromote: '',
					sDemote: '',
					listStr: {},
					delete: true,
					expired: 0,
				}
			let settings = global.db.data.settings[this.user.jid]
			if (typeof settings !== 'object') global.db.data.settings[this.user.jid] = {}
			if (settings) {
				if (!('self' in settings)) settings.self = false
				if (!('autoread' in settings)) settings.autoread = true
				if (!('anticall' in settings)) settings.anticall = true
				if (!('pconlyprem' in settings)) settings.pconlyprem = false
				if (!('maintenance' in settings)) settings.maintenance = false
			} else global.db.data.settings[this.user.jid] = {
				self: false,
				autoread: true,
				anticall: true,
				pconlyprem: false,
				maintenance: false, 
			}
		} catch (e) {
			console.error(e)
		}

		if (opts['nyimak'])
			return
		if (!m.fromMe && opts['self'])
			return
		if (opts['pconly'] && m.chat.endsWith('g.us'))
			return
		if (opts['gconly'] && !m.chat.endsWith('g.us'))
			return
		if (opts['swonly'] && m.chat !== 'status@broadcast')
			return
		if (typeof m.text !== 'string')
			m.text = ''

		//const isROwner = [global.conn.user.jid, ...global.owner].map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender)
		const isROwner = [global.conn.user.jid, ...global.owner, ...global.hsb].map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender)
		const isOwner = isROwner
		const isMods = isOwner || m.fromMe || global.mods.map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender)
		const isPrems = isROwner || isMods || (db.data.users[m.sender].premiumTime > 0 || db.data.users[m.sender].premium)

		if (opts['queque'] && m.text && !(isMods || isPrems)) {
			let queque = this.msgqueque,
				time = 1000 * 5
			const previousID = queque[queque.length - 1]
			queque.push(m.id || m.key.id)
			setInterval(async function() {
				if (queque.indexOf(previousID) === -1) clearInterval(this)
				await delay(time)
			}, time)
		}

		//if (m.id.startsWith('BAE5') && m.id.length === 16 || m.isBaileys && m.fromMe) return
		if (m.id.startsWith('3EB0') || (m.id.startsWith('BAE5') && m.id.length === 16) || m.isBaileys && m.fromMe) return;
		m.exp += Math.ceil(Math.random() * 10)

		let usedPrefix
		let _user = global.db.data && global.db.data.users && global.db.data.users[m.sender]

		const groupMetadata = (m.isGroup ? ((conn.chats[m.chat] || {}).metadata || await this.groupMetadata(m.chat).catch(_ => null)) : {}) || {}
		const participants = (m.isGroup ? groupMetadata.participants : []) || []
		const user = (m.isGroup ? participants.find(u => conn.decodeJid(u.id) === m.sender) : {}) || {} // User Data
		const bot = (m.isGroup ? participants.find(u => conn.decodeJid(u.id) == this.user.jid) : {}) || {} // Your Data
		const isRAdmin = user?.admin == 'superadmin' || false
		const isAdmin = isRAdmin || user?.admin == 'admin' || false // Is User Admin?
		const isBotAdmin = bot?.admin || false // Are you Admin?

		const ___dirname = path.join(path.dirname(fileURLToPath(import.meta.url)), './plugins')
		for (let name in global.plugins) {
			let plugin = global.plugins[name]
			if (!plugin)
				continue
			if (plugin.disabled)
				continue
			const __filename = join(___dirname, name)
			if (typeof plugin.all === 'function') {
				try {
					await plugin.all.call(this, m, {
						chatUpdate,
						__dirname: ___dirname,
						__filename
					})
				} catch (e) {
					// if (typeof e === 'string') continue
					console.error(e)
					for (let [jid] of global.owner.filter(([number, _, isDeveloper]) => isDeveloper && number)) {
						let data = (await conn.onWhatsApp(jid))[0] || {}
						if (data.exists)
							m.reply(`*Plugin:* ${name}\n*Sender:* ${m.sender}\n*Chat:* ${m.chat}\n*Command:* ${m.text}\n\n\`\`\`${format(e)}\`\`\``.trim(), data.jid)
					}
				}
			}
			if (!opts['restrict'])
				if (plugin.tags && plugin.tags.includes('admin')) {
					// global.dfail('restrict', m, this)
					continue
				}
			const str2Regex = str => str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
			let _prefix = plugin.customPrefix ? plugin.customPrefix : conn.prefix ? conn.prefix : global.prefix
			let match = (_prefix instanceof RegExp ? // RegExp Mode?
				[
					[_prefix.exec(m.text), _prefix]
				] :
				Array.isArray(_prefix) ? // Array?
				_prefix.map(p => {
					let re = p instanceof RegExp ? // RegExp in Array?
						p :
						new RegExp(str2Regex(p))
					return [re.exec(m.text), re]
				}) :
				typeof _prefix === 'string' ? // String?
				[
					[new RegExp(str2Regex(_prefix)).exec(m.text), new RegExp(str2Regex(_prefix))]
				] : [
					[
						[], new RegExp
					]
				]
			).find(p => p[1])
			if (typeof plugin.before === 'function') {
				if (await plugin.before.call(this, m, {
						match,
						conn: this,
						participants,
						groupMetadata,
						user,
						bot,
						isROwner,
						isOwner,
						isRAdmin,
						isAdmin,
						isBotAdmin,
						isPrems,
						chatUpdate,
						__dirname: ___dirname,
						__filename
					}))
					continue
			}
			if (typeof plugin !== 'function')
				continue
			if ((usedPrefix = (match[0] || '')[0])) {
				let noPrefix = m.text.replace(usedPrefix, '')
				let [command, ...args] = noPrefix.trim().split` `.filter(v => v)
				args = args || []
				let _args = noPrefix.trim().split` `.slice(1)
				let text = _args.join` `
				command = (command || '').toLowerCase()
				let fail = plugin.fail || global.dfail // When failed
				let isAccept = plugin.command instanceof RegExp ? // RegExp Mode?
					plugin.command.test(command) :
					Array.isArray(plugin.command) ? // Array?
					plugin.command.some(cmd => cmd instanceof RegExp ? // RegExp in Array?
						cmd.test(command) : cmd === command) : typeof plugin.command === 'string' ? // String?
					plugin.command === command : false

				if (!isAccept)
					continue
				m.plugin = name
				if (m.chat in global.db.data.chats || m.sender in global.db.data.users) {
					let chat = global.db.data.chats[m.chat]
					let user = global.db.data.users[m.sender]
					let ban = db.data.banned[m.sender]
					if (typeof ban !== 'undefined' && ban.status)
						return
					if (name != 'owner-unbanchat.js' && name != 'owner-exec.js' && name != 'owner-exec2.js' && name != 'tool-delete.js' && name != 'mode-bot.js' && chat?.isBanned)
						return
					if (name != 'owner-unbanuser.js' && name != 'owner-exec.js' && name != 'owner-exec2.js' && name != 'info-cekbanned.js' && name != 'cek-banned.js' && user?.banned)
						return
					if (global.db.data.settings.pconlyprem && !user.premium && !m.isGroup)
					    return
					if (global.db.data.settings.maintenance && !isROwner && !isOwner) 
					    return
				}
				if (plugin.rowner && plugin.owner && !(isROwner || isOwner)) {
					fail('owner', m, this)
					continue
				}
				if (plugin.rowner && !isROwner) {
					fail('rowner', m, this)
					continue
				}
				if (plugin.owner && !isOwner) {
					fail('owner', m, this)
					continue
				}
				if (plugin.mods && !isMods) {
					fail('mods', m, this)
					continue
				}
				if (plugin.premium && !isPrems) {
					fail('premium', m, this)
					continue
				}
				if (plugin.group && !m.isGroup) {
					fail('group', m, this)
					continue
				} else if (plugin.botAdmin && !isBotAdmin) {
					fail('botAdmin', m, this)
					continue
				} else if (plugin.admin && !isAdmin) {
					fail('admin', m, this)
					continue
				}
				if (plugin.private && m.isGroup) {
					fail('private', m, this)
					continue
				}
				if (plugin.register && !_user.registered) {
					fail('unreg', m, this)
					continue
				}
				if (plugin.onlyprem && !m.isGroup && !isPrems) {
					fail('onlyprem', m, this)
					continue
				}
				m.isCommand = true
				let xp = 'exp' in plugin ? parseInt(plugin.exp) : 17 // XP Earning per command
				if (xp > 200)
					m.reply('Ngecit -_-') // Hehehe
				else
					m.exp += xp
				if (!isPrems && plugin.energy && _user.energy < plugin.energy * 1) {
					m.reply(global.pricelist);
					continue
				}
				if (plugin.level > _user.level) {
					this.reply(m.chat, `[💬] Mohon maaf level yang di perlukan untuk menggunakan fitur ini ${plugin.level}\n*Level mu:* ${_user.level} 📊`, m)
					continue
				}
				if (plugin.age > _user.age) {
					this.reply(m.chat, `[💬] Umurmu harus diatas ${plugin.age} Tahun untuk menggunakan fitur ini...`, m)
					continue
				}
				let isCmddd = /^[°•π÷×¶∆£¢€¥®™+✓_=|~!?@#$%^&.©^]/gi.test(m.text)
				if (isCmddd && !isPrems && !m.isGroup && !conn.werewolf && !conn.orderkouta) {
//			       this.sendMessage(m.chat, { text: `⚠️ Menggunakan bot dalam obrolan pribadi hanya untuk pengguna premium.\n\n*PREMIUM USER PRICE LIST*\n\n*3 Day premium*\n- OrderID: 3\n- Price: Rp. 5.000 IDR\n\n*7 Day premium*\n- OrderID: 7\n- Price: Rp. 10.000 IDR\n\n*30 Day premium*\n- OrderID: 30\n- Price: Rp. 15.000 IDR\n\n*60 Day premium*\n- OrderID: 60\n- Price: Rp. 30.000 IDR\n\n*90 Day premium*\n- OrderID: 90\n- Price: Rp. 40.000 IDR\n\n*365 Day premium*\n- OrderID: 365\n- Price: Rp. 115.000 IDR\n\nTolong ikuti cara pembayaran ini.\n\nSilahkan tulis seperti ini : *.order <OrderID>*\nContoh: *.order 30*\n\nJika anda terlalu bodoh. anda bisa langsung menghubungi nomor owner kami melalui link di bawah ini:\nwa.me/${global.info.nomorown}\n\nThank you for using our bot #MaximusStore`, contextInfo: { mentionedJid: [m.sender], externalAdReply: { title: '', body: '', thumbnailUrl: "https://telegra.ph/file/0b32e0a0bb3b81fef9838.jpg", sourceUrl: "", mediaType: 1, renderLargerThumbnail: true }} })
			    	continue
				}
				let extra = {
					match,
					usedPrefix,
					noPrefix,
					_args,
					args,
					command,
					text,
					conn: this,
					participants,
					groupMetadata,
					user,
					bot,
					isROwner,
					isOwner,
					isRAdmin,
					isAdmin,
					isBotAdmin,
					isPrems,
					chatUpdate,
					__dirname: ___dirname,
					__filename
				}
				try {
					await plugin.call(this, m, extra)
					if (!isPrems)
						m.energy = m.energy || plugin.energy || false
				} catch (e) {
					// Error occured
					m.error = e
					console.error(e)
					if (e) {
						let text = format(e)
						for (let key of Object.values(global.APIKeys))
							text = text.replace(new RegExp(key, 'g'), '#HIDDEN#')
						if (e.name)
							for (let [jid] of global.owner.filter(([number, _, isDeveloper]) => isDeveloper && number)) {
								let data = (await conn.onWhatsApp(jid))[0] || {}
								if (data.exists)
									m.reply(`*🗂️ Plugin:* ${m.plugin}\n*👤 Sender:* ${m.sender}\n*💬 Chat:* ${m.chat}\n*💻 Command:* ${usedPrefix}${command} ${args.join(' ')}\n📄 *Error Logs:*\n\n\`\`\`${text}\`\`\``.trim(), data.jid)
							}
						m.reply(text)
					}
				} finally {
					// m.reply(util.format(_user))
					if (typeof plugin.after === 'function') {
						try {
							await plugin.after.call(this, m, extra)
						} catch (e) {
							console.error(e)
						}
					}
					//if (m.energy)
					   //await m.reply(`⚡ Energi -` + m.energy)
				}
				break
			}
		}
	} catch (e) {
		console.error(e)
	} finally {
		if (opts['queque'] && m.text) {
			const quequeIndex = this.msgqueque.indexOf(m.id || m.key.id)
			if (quequeIndex !== -1)
				this.msgqueque.splice(quequeIndex, 1)
		}
		//console.log(global.db.data.users[m.sender])
		let user,
			stats = global.db.data.stats
		if (m) {
			if (m.sender && (user = global.db.data.users[m.sender])) {
				user.exp += m.exp
				user.energy -= m.energy * 1
			}

			let stat
			if (m.plugin) {
				let now = +new Date
				if (m.plugin in stats) {
					stat = stats[m.plugin]
					if (!isNumber(stat.total))
						stat.total = 1
					if (!isNumber(stat.success))
						stat.success = m.error != null ? 0 : 1
					if (!isNumber(stat.last))
						stat.last = now
					if (!isNumber(stat.lastSuccess))
						stat.lastSuccess = m.error != null ? 0 : now
				} else
					stat = stats[m.plugin] = {
						total: 1,
						success: m.error != null ? 0 : 1,
						last: now,
						lastSuccess: m.error != null ? 0 : now
					}
				stat.total += 1
				stat.last = now
				if (m.error == null) {
					stat.success += 1
					stat.lastSuccess = now
				}
			}
		}

		try {
			if (!opts['noprint']) await printMessage(m, this)
		} catch (e) {
			console.log(m, m.quoted, e)
		}
		if (global.db.data.settings[this.user.jid].autoread)
			await this.readMessages([m.key]).catch(() => {})

		if (global.db.data.settings[this.user.jid].composing)
			await this.sendPresenceUpdate('composing', m.chat).catch(() => {})
	}
}

/**
 * Handle groups participants update
 * @param {import('baileys').BaileysEventMap<unknown>['group-participants.update']} groupsUpdate
 */
export async function participantsUpdate({
	id,
	participants,
	action
}) {
	if (opts['self'])
		return
	if (this.isInit)
		return
	let chat = global.db.data.chats[id] || {}
	let text = ''
	switch (action) {
		case 'add':
			if (chat.welcome) {
				let groupMetadata = await this.groupMetadata(id) || (conn.chats[id] || {}).metadata
				for (let user of participants) {
					let pp = fs.readFileSync('./src/avatar_contact.png')
					try {
						pp = await this.profilePictureUrl(user, 'image')
					} catch (e) {} finally {
						text = (action === 'add' ? (chat.sWelcome || this.welcome || conn.welcome || 'Welcome, @user!').replace('@subject', await this.getName(id)).replace('@desc', groupMetadata.desc ? String.fromCharCode(8206).repeat(4001) + groupMetadata.desc : '') :
							(chat.sBye || this.bye || conn.bye || 'Bye, @user!')).replace('@user', '@' + user.split('@')[0])
						let wel = 'https://telegra.ph/file/6922e4375c183c8d1cfcb.jpg'
						
						await this.sendMessage(id, { text: text, contextInfo: { mentionedJid: [user] }}, { quoted: null })

					}
				}
			}
			break
		case 'remove':
			if (chat.goodbye) {
				let groupMetadata = await this.groupMetadata(id) || (conn.chats[id] || {}).metadata
				for (let user of participants) {
					let pp = fs.readFileSync('./src/avatar_contact.png')
					try {
						pp = await this.profilePictureUrl(user, 'image')
					} catch (e) {} finally {
						text = (action === 'add' ? (chat.sWelcome || this.welcome || conn.welcome || 'Welcome, @user!').replace('@subject', await this.getName(id)).replace('@desc', groupMetadata.desc ? String.fromCharCode(8206).repeat(4001) + groupMetadata.desc : '') :
							(chat.sBye || this.bye || conn.bye || 'Bye, @user!')).replace('@user', '@' + user.split('@')[0])
						let lea = 'https://telegra.ph/file/8c7792e78ed015a7d0a59.jpg'
						
						await this.sendMessage(id, { text: text, contextInfo: { mentionedJid: [user] }}, { quoted: null })

					}
				}
			}
			break
		case 'promote':
			text = (chat.sPromote || this.spromote || conn.spromote || '@user ```is now Admin```')
		case 'demote':
			if (!text)
				text = (chat.sDemote || this.sdemote || conn.sdemote || '@user ```is no longer Admin```')
			text = text.replace('@user', '@' + participants[0].split('@')[0])
			if (chat.detect)
				this.sendMessage(id, {
					text,
					mentions: this.parseMention(text)
				})
			break
	}
}
/**
 * Handle groups update
 * @param {import('baileys').BaileysEventMap<unknown>['groups.update']} groupsUpdate
 */
export async function groupsUpdate(groupsUpdate) {
	if (opts['self'])
		return
	for (const groupUpdate of groupsUpdate) {
		const id = groupUpdate.id
		if (!id) continue
		let chats = global.db.data.chats[id],
			text = ''
		if (!chats?.detect) continue
		if (groupUpdate.desc) text = (chats.sDesc || this.sDesc || conn.sDesc || '```Description has been changed to```\n@desc').replace('@desc', groupUpdate.desc)
		if (groupUpdate.subject) text = (chats.sSubject || this.sSubject || conn.sSubject || '```Subject has been changed to```\n@subject').replace('@subject', groupUpdate.subject)
		if (groupUpdate.icon) text = (chats.sIcon || this.sIcon || conn.sIcon || '```Icon has been changed to```').replace('@icon', groupUpdate.icon)
		if (groupUpdate.revoke) text = (chats.sRevoke || this.sRevoke || conn.sRevoke || '```Group link has been changed to```\n@revoke').replace('@revoke', groupUpdate.revoke)
		if (!text) continue
		await this.sendMessage(id, {
			text,
			mentions: this.parseMention(text)
		})
	}
}

export async function deleteUpdate(message) {
	try {
		const {
			fromMe,
			id,
			participant
		} = message
		if (fromMe)
			return
		let msg = this.serializeM(this.loadMessage(id))
		if (!msg)
			return
		let chat = global.db.data.chats[msg.chat] || {}
		if (chat.delete)
			return
		await this.reply(msg.chat, `
⧻Terdeteksi @${participant.split`@`[0]} telah menghapus pesan
Untuk mematikan fitur ini, Admin harus mengetik 
*.disable antidelete*
`.trim(), msg, {
			mentions: [participant]
		})
		this.copyNForward(msg.chat, msg).catch(e => console.log(e, msg))
	} catch (e) {
		console.error(e)
	}
}

global.dfail = (type, m, conn) => {
	let msg = {
		rowner: 'Perintah ini hanya untuk *R-OWNER*',
		owner: 'Perintah ini hanya untuk *OWNER*',
		mods: 'Perintah ini hanya untuk *MODS*',
		premium: 'Perintah ini hanya untuk *USER PREMIUM*',
		group: 'Perintah ini hanya untuk *GROUPS*',
		private: 'Perintah ini hanya untuk *PRIVATE MESSAGE*',
		admin: 'Perintah ini hanya untuk *ADMIN*',
		botAdmin: 'Perintah ini hanya untuk *BOT-ADMINS*',
		onlyprem: 'Perintah ini hanya untuk *USER PREMIUM*',
		nsfw: 'Perintah ini belum diaktifkan di grup ini.\n\n> Aktifkan Fitur Ini Dengan Mengetik *.enable nsfw*',
		rpg: 'Perintah ini belum diaktifkan di grup ini.\n\n> Aktifkan Fitur Ini Dengan Mengetik *.enable rpg*',
		game: 'Perintah Ini Belum Diaktifkan Di Grup Ini.\n\n> Aktifkan Fitur Ini Dengan Mengetik *.enable game*',
		restrict: '*FITUR DIMATIKAN OLEH OWNER*',
		unreg: '*Silakan mendaftar terlebih dahulu dengan mengetik \`#daftar name.age\`*\n\n* *Setelah Anda terdaftar, maka Anda dapat menggunakan perintah ini.*\n\n*Contoh pendaftaran:*\n\n\`#daftar gon.18\`\n\n*Catatan:*\n- Gunakan nama asli dan umur yang benar\n- Jika sudah mendaftar maka kamu tidak perlu mendaftar lagi'
	} [type]

	if (msg) return conn.sendMessage(m.chat, { text: `*Hi @${m.sender.split('@')[0]} 👋🏻*\n\n` + msg, contextInfo: { mentionedJid: [m.sender] }})
}

let file = global.__filename(import.meta.url, true)
watchFile(file, async () => {
	unwatchFile(file)
	console.log(chalk.redBright("Update 'handler.js'"))
	if (global.reloadHandler) console.log(await global.reloadHandler())
})

function ucapan() {
	const time = moment.tz('Asia/Jakarta').format('HH')
	let res = "Sudah Dini Hari Kok Belum Tidur Kak? ??"
	if (time >= 4) {
		res = "Selamat Pagi"
	}
	if (time >= 10) {
		res = "Selamat Siang"
	}
	if (time >= 15) {
		res = "Selamat Sore"
	}
	if (time >= 18) {
		res = "Selamat Malam"
	}
	return res
}
Assistant: