Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-mini-2024-07-18· OpenAIAi2 WildChat-4.8M (AI2)

tolong sempurnakan kode ini karna dia tidak bisa welcome on dan sejenisnya atau…

  1. User

    User: tolong sempurnakan kode ini karna dia tidak bisa welcome on dan sejenisnya atau dia tidak bisa on/off di belakang tolong agar support keduanya mau on di depan atau di akhir import moment from 'moment-timezone' import fs from 'fs' let handler = async (m, { conn, usedPrefix, command, args, isOwner, isAdmin, }) => { 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 bot = global.db.data.settings[conn.user.jid] || {} let name = ${user.registered ? user.name : conn.getName(m.sender)} let type = (args[0] || '').toLowerCase() let isAll = false, isUser = false let caption = ` ❏ ADMIN COMMAND

    ⩽⩾ autodownload chat.autoDownload?′∗(ON)∗′:′∗(OFF)∗′⩽⩾autobio{chat.autoDownload ? '*( ON )*' : '*( OFF )*'} ⩽⩾ autobio {chat.autobio ? '( ON )' : '( OFF )'} ⩽⩾ detect chat.detect?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antilink{chat.detect ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antilink {chat.antiLink ? '( ON )' : '( OFF )'} ⩽⩾ antilinkwa chat.antiLinkWa?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antitoxic{chat.antiLinkWa ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antitoxic {chat.antiToxic ? '( ON )' : '( OFF )'} ⩽⩾ antibadword chat.antiBadword?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antidelete{chat.antiBadword ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antidelete {chat.delete ? '( ON )' : '( OFF )'} ⩽⩾ antiviewonce chat.viewonce?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antisticker{chat.viewonce ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antisticker {chat.antiSticker ? '( ON )' : '( OFF )'} ⩽⩾ antivirtex chat.antiVirtex?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antifoto{chat.antiVirtex ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antifoto {chat.antiFoto ? '( ON )' : '( OFF )'} ⩽⩾ antivideo chat.antiVideo?′∗(ON)∗′:′∗(OFF)∗′⩽⩾simi{chat.antiVideo ? '*( ON )*' : '*( OFF )*'} ⩽⩾ simi {chat.simi ? '( ON )' : '( OFF )'} ⩽⩾ text chat.teks?′∗(ON)∗′:′∗(OFF)∗′⩽⩾restrict{chat.teks ? '*( ON )*' : '*( OFF )*'} ⩽⩾ restrict {chat.pembatasan ? '( ON )' : '( OFF )'} ⩽⩾ game chat.game?′∗(ON)∗′:′∗(OFF)∗′⩽⩾rpg{chat.game ? '*( ON )*' : '*( OFF )*'} ⩽⩾ rpg {chat.rpg ? '( ON )' : '( OFF )'} ⩽⩾ nsfw chat.nsfw?′∗(ON)∗′:′∗(OFF)∗′⩽⩾welcome{chat.nsfw ? '*( ON )*' : '*( OFF )*'} ⩽⩾ welcome {chat.welcome ? '( ON )' : '( OFF )'} ⩽⩾ left chat.bye?′∗(ON)∗′:′∗(OFF)∗′⩽⩾autolevelup{chat.bye ? '*( ON )*' : '*( OFF )*'} ⩽⩾ autolevelup {chat.autolevelup ? '( ON )' : '( OFF )'}

    ❏ OWNER COMMAND

    ⩽⩾ autosholat bot.sholat?′∗(ON)∗′:′∗(OFF)∗′⩽⩾autobackup{bot.sholat ? '*( ON )*' : '*( OFF )*'} ⩽⩾ autobackup {bot.backup ? '( ON )' : '( OFF )'} ⩽⩾ autocleartmp bot.cleartmp?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antispam{bot.cleartmp ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antispam {bot.antispam ? '( ON )' : '( OFF )'} ⩽⩾ autoread bot.autoread?′∗(ON)∗′:′∗(OFF)∗′⩽⩾composing{bot.autoread ? '*( ON )*' : '*( OFF )*'} ⩽⩾ composing {bot.composing ? '( ON )' : '( OFF )'} ⩽⩾ pconlyprem opts.pconlyprem?′∗(ON)∗′:′∗(OFF)∗′⩽⩾pconly{opts.pconlyprem ? '*( ON )*' : '*( OFF )*'} ⩽⩾ pconly {opts.pconly ? '( ON )' : '( OFF )'} ⩽⩾ self opts.self?′∗(ON)∗′:′∗(OFF)∗′⩽⩾public{opts.self ? '*( ON )*' : '*( OFF )*'} ⩽⩾ public {!opts.self ? '( ON )' : '( OFF )'} ⩽⩾ swonly opts.swonly?′∗(ON)∗′:′∗(OFF)∗′⩽⩾anticall{opts.swonly ? '*( ON )*' : '*( OFF )*'} ⩽⩾ anticall {bot.anticall ? '( ON )' : '( OFF )'} ⩽⩾ limit_mode opts.limitmode?′∗(ON)∗′:′∗(OFF)∗′⩽⩾premiummode{opts.limit_mode ? '*( ON )*' : '*( OFF )*'} ⩽⩾ premium_mode {opts.premium_mode ? '( ON )' : '( OFF )'} .trim() switch (type) { case 'welcome': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.welcome = isEnable break case 'left': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.bye = isEnable break case 'autolevelup': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.autolevelup = isEnable break case 'autodownload': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.autoDownload = isEnable break case 'adminonly': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.adminonly = isEnable break case 'antifoto': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiFoto = isEnable break case 'antibot': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiBot = isEnable break case 'autosholat': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.autoSholat = isEnable break case 'antivideo': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiVideo = isEnable break case 'autobio': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } bot.autoBio = isEnable break case 'detect': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.detect = isEnable break case 'delete': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.delete = isEnable break case 'antiviewonce': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.viewonce = isEnable break case 'antidelete': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.delete = !isEnable break case 'antispamlink': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antispam = isEnable break case 'text': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.teks = isEnable break case 'public': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global.opts['self'] = !isEnable break case 'antilink': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiLink = isEnable break case 'antilinkwa': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiLinkWa = isEnable break case 'nsfw': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.nsfw = isEnable break case 'rpg': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.rpg = isEnable break case 'antivirtex': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiVirtex = isEnable break case 'simi': if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } chat.simi = isEnable break case 'composing': if (!isOwner) { global.dfail('rowner', m, conn) throw false } bot.composing = isEnable break case 'antisticker': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiSticker = isEnable break case 'antibadword': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiBadword = isEnable break case 'antitoxic': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiToxic = isEnable break case 'restrict': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.pembatasan = isEnable break case 'game': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.game = isEnable break case 'anticall': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } bot.anticall = isEnable break case 'whitelistmycontacts': if (!isOwner) { global.dfail('owner', m, conn) throw false } conn.callWhitelistMode = isEnable break case 'autobackup': isAll = true if (!isOwner) { global.dfail('owner', m, conn) throw false } bot.backup = isEnable break case 'autocleartmp': isAll = true if (!isOwner) { global.dfail('owner', m, conn) throw false } bot.cleartmp = isEnable break case 'antispam': isAll = true if (!isOwner) { global.dfail('owner', m, conn) throw false } bot.antispam = isEnable break case 'autoread': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } bot.autoread = isEnable break case 'pconly': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global.opts['pconly'] = isEnable break case 'premium_mode': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global['premium_mode'] = isEnable break case 'limit_mode': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global['limit_mode'] = isEnable break case 'gconly': case 'pconlyprem': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global.onlygc['on'] = isEnable break case 'swonly': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global.opts['swonly'] = isEnable break default: return conn.adReply(m.chat, caption, wish() + ' ' + name, '', fs.readFileSync('./media/thumbnail.jpg'), '', m) } await m.reply(typeberhasil{type} berhasil {isEnable ? 'dinyalakan': 'dimatikan'} untuk {isAll ? 'bot ini': 'chat ini'} !`) } handler.help = ['enable <command>'] handler.tags = ['group', 'adminry'] handler.command = /^((en|dis)able|setting|settings|(tru|fals)e|(turn)?o(n|ff)|[01])/i

    export default handler

    function wish() { let wishloc = '' const time = moment.tz('Asia/Jakarta').format('HH') wishloc = ('Hi') if (time >= 0) { wishloc = ('Selamat Malam') } if (time >= 4) { wishloc = ('Selamat Pagi') } if (time >= 11) { wishloc = ('Selamat Siang') } if (time >= 15) { wishloc = ('️Selamat Sore') } if (time >= 18) { wishloc = ('Selamat Malam') } if (time >= 23) { wishloc = ('Selamat Malam') } return wishloc } User: tolong sempurnakan kode ini karna dia tidak bisa welcome on dan sejenisnya atau dia tidak bisa on/off di belakang tolong agar support keduanya mau on di depan atau di akhir import moment from 'moment-timezone' import fs from 'fs' let handler = async (m, { conn, usedPrefix, command, args, isOwner, isAdmin, }) => { 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 bot = global.db.data.settings[conn.user.jid] || {} let name = ${user.registered ? user.name : conn.getName(m.sender)} let type = (args[0] || '').toLowerCase() let isAll = false, isUser = false let caption = ` ❏ ADMIN COMMAND

    ⩽⩾ autodownload chat.autoDownload?′∗(ON)∗′:′∗(OFF)∗′⩽⩾autobio{chat.autoDownload ? '*( ON )*' : '*( OFF )*'} ⩽⩾ autobio {chat.autobio ? '( ON )' : '( OFF )'} ⩽⩾ detect chat.detect?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antilink{chat.detect ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antilink {chat.antiLink ? '( ON )' : '( OFF )'} ⩽⩾ antilinkwa chat.antiLinkWa?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antitoxic{chat.antiLinkWa ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antitoxic {chat.antiToxic ? '( ON )' : '( OFF )'} ⩽⩾ antibadword chat.antiBadword?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antidelete{chat.antiBadword ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antidelete {chat.delete ? '( ON )' : '( OFF )'} ⩽⩾ antiviewonce chat.viewonce?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antisticker{chat.viewonce ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antisticker {chat.antiSticker ? '( ON )' : '( OFF )'} ⩽⩾ antivirtex chat.antiVirtex?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antifoto{chat.antiVirtex ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antifoto {chat.antiFoto ? '( ON )' : '( OFF )'} ⩽⩾ antivideo chat.antiVideo?′∗(ON)∗′:′∗(OFF)∗′⩽⩾simi{chat.antiVideo ? '*( ON )*' : '*( OFF )*'} ⩽⩾ simi {chat.simi ? '( ON )' : '( OFF )'} ⩽⩾ text chat.teks?′∗(ON)∗′:′∗(OFF)∗′⩽⩾restrict{chat.teks ? '*( ON )*' : '*( OFF )*'} ⩽⩾ restrict {chat.pembatasan ? '( ON )' : '( OFF )'} ⩽⩾ game chat.game?′∗(ON)∗′:′∗(OFF)∗′⩽⩾rpg{chat.game ? '*( ON )*' : '*( OFF )*'} ⩽⩾ rpg {chat.rpg ? '( ON )' : '( OFF )'} ⩽⩾ nsfw chat.nsfw?′∗(ON)∗′:′∗(OFF)∗′⩽⩾welcome{chat.nsfw ? '*( ON )*' : '*( OFF )*'} ⩽⩾ welcome {chat.welcome ? '( ON )' : '( OFF )'} ⩽⩾ left chat.bye?′∗(ON)∗′:′∗(OFF)∗′⩽⩾autolevelup{chat.bye ? '*( ON )*' : '*( OFF )*'} ⩽⩾ autolevelup {chat.autolevelup ? '( ON )' : '( OFF )'}

    ❏ OWNER COMMAND

    ⩽⩾ autosholat bot.sholat?′∗(ON)∗′:′∗(OFF)∗′⩽⩾autobackup{bot.sholat ? '*( ON )*' : '*( OFF )*'} ⩽⩾ autobackup {bot.backup ? '( ON )' : '( OFF )'} ⩽⩾ autocleartmp bot.cleartmp?′∗(ON)∗′:′∗(OFF)∗′⩽⩾antispam{bot.cleartmp ? '*( ON )*' : '*( OFF )*'} ⩽⩾ antispam {bot.antispam ? '( ON )' : '( OFF )'} ⩽⩾ autoread bot.autoread?′∗(ON)∗′:′∗(OFF)∗′⩽⩾composing{bot.autoread ? '*( ON )*' : '*( OFF )*'} ⩽⩾ composing {bot.composing ? '( ON )' : '( OFF )'} ⩽⩾ pconlyprem opts.pconlyprem?′∗(ON)∗′:′∗(OFF)∗′⩽⩾pconly{opts.pconlyprem ? '*( ON )*' : '*( OFF )*'} ⩽⩾ pconly {opts.pconly ? '( ON )' : '( OFF )'} ⩽⩾ self opts.self?′∗(ON)∗′:′∗(OFF)∗′⩽⩾public{opts.self ? '*( ON )*' : '*( OFF )*'} ⩽⩾ public {!opts.self ? '( ON )' : '( OFF )'} ⩽⩾ swonly opts.swonly?′∗(ON)∗′:′∗(OFF)∗′⩽⩾anticall{opts.swonly ? '*( ON )*' : '*( OFF )*'} ⩽⩾ anticall {bot.anticall ? '( ON )' : '( OFF )'} ⩽⩾ limit_mode opts.limitmode?′∗(ON)∗′:′∗(OFF)∗′⩽⩾premiummode{opts.limit_mode ? '*( ON )*' : '*( OFF )*'} ⩽⩾ premium_mode {opts.premium_mode ? '( ON )' : '( OFF )'} .trim() switch (type) { case 'welcome': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.welcome = isEnable break case 'left': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.bye = isEnable break case 'autolevelup': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.autolevelup = isEnable break case 'autodownload': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.autoDownload = isEnable break case 'adminonly': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.adminonly = isEnable break case 'antifoto': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiFoto = isEnable break case 'antibot': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiBot = isEnable break case 'autosholat': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.autoSholat = isEnable break case 'antivideo': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiVideo = isEnable break case 'autobio': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } bot.autoBio = isEnable break case 'detect': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.detect = isEnable break case 'delete': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.delete = isEnable break case 'antiviewonce': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.viewonce = isEnable break case 'antidelete': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.delete = !isEnable break case 'antispamlink': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antispam = isEnable break case 'text': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.teks = isEnable break case 'public': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global.opts['self'] = !isEnable break case 'antilink': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiLink = isEnable break case 'antilinkwa': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiLinkWa = isEnable break case 'nsfw': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.nsfw = isEnable break case 'rpg': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.rpg = isEnable break case 'antivirtex': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiVirtex = isEnable break case 'simi': if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } chat.simi = isEnable break case 'composing': if (!isOwner) { global.dfail('rowner', m, conn) throw false } bot.composing = isEnable break case 'antisticker': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiSticker = isEnable break case 'antibadword': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiBadword = isEnable break case 'antitoxic': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.antiToxic = isEnable break case 'restrict': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.pembatasan = isEnable break case 'game': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } chat.game = isEnable break case 'anticall': if (m.isGroup) { if (!(isAdmin || isOwner)) { global.dfail('admin', m, conn) throw false } } bot.anticall = isEnable break case 'whitelistmycontacts': if (!isOwner) { global.dfail('owner', m, conn) throw false } conn.callWhitelistMode = isEnable break case 'autobackup': isAll = true if (!isOwner) { global.dfail('owner', m, conn) throw false } bot.backup = isEnable break case 'autocleartmp': isAll = true if (!isOwner) { global.dfail('owner', m, conn) throw false } bot.cleartmp = isEnable break case 'antispam': isAll = true if (!isOwner) { global.dfail('owner', m, conn) throw false } bot.antispam = isEnable break case 'autoread': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } bot.autoread = isEnable break case 'pconly': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global.opts['pconly'] = isEnable break case 'premium_mode': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global['premium_mode'] = isEnable break case 'limit_mode': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global['limit_mode'] = isEnable break case 'gconly': case 'pconlyprem': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global.onlygc['on'] = isEnable break case 'swonly': isAll = true if (!isOwner) { global.dfail('rowner', m, conn) throw false } global.opts['swonly'] = isEnable break default: return conn.adReply(m.chat, caption, wish() + ' ' + name, '', fs.readFileSync('./media/thumbnail.jpg'), '', m) } await m.reply(typeberhasil{type} berhasil {isEnable ? 'dinyalakan': 'dimatikan'} untuk {isAll ? 'bot ini': 'chat ini'} !`) } handler.help = ['enable <command>'] handler.tags = ['group', 'adminry'] handler.command = /^((en|dis)able|setting|settings|(tru|fals)e|(turn)?o(n|ff)|[01])/i

    export default handler

    function wish() { let wishloc = '' const time = moment.tz('Asia/Jakarta').format('HH') wishloc = ('Hi') if (time >= 0) { wishloc = ('Selamat Malam') } if (time >= 4) { wishloc = ('Selamat Pagi') } if (time >= 11) { wishloc = ('Selamat Siang') } if (time >= 15) { wishloc = ('️Selamat Sore') } if (time >= 18) { wishloc = ('Selamat Malam') } if (time >= 23) { wishloc = ('Selamat Malam') } return wishloc } Assistant:

  2. Assistant

    To improve your code and ensure that it can recognize both command formats (i.e., command on and command off), you will need to enhance the way you determine whether the command is an enabling or disabling command. Below is a modified version of your code that accomplishes this:

    import moment from 'moment-timezone';
    import fs from 'fs';
    
    let handler = async (m, { conn, usedPrefix, command, args, isOwner, isAdmin }) => {
        // Create a regex to check if the command is for turning on/off
        let isEnable = /true|enable|(turn)?on|1/i.test(args[1]);
        let chat = global.db.data.chats[m.chat];
        let user = global.db.data.users[m.sender];
        let bot = global.db.data.settings[conn.user.jid] || {};
        let name = `${user.registered ? user.name : conn.getName(m.sender)}`;
        let type = (args[0] || '').toLowerCase();
        let isAll = false;
    
        // Check if args[1] is provided, if not, default to the command state
        if (!isEnable && args.length > 1) {
            isEnable = /false|disable|(turn)?off|0/i.test(args[1]);
        }
    
        let caption = `
    _*❏ ADMIN COMMAND*_
    ... // (summary as before)
    `.trim();
    
        // Validate group command permissions
        const validateAdmin = () => {
            if (m.isGroup && !(isAdmin || isOwner)) {
                global.dfail('admin', m, conn);
                throw false;
            }
        };
    
        switch (type) {
            // Group of cases for enabling/disabling settings
            case 'welcome':
                validateAdmin();
                chat.welcome = isEnable;
                break;
            case 'left':
                validateAdmin();
                chat.bye = isEnable;
                break;
            case 'autolevelup':
                validateAdmin();
                chat.autolevelup = isEnable;
                break;
            case 'autodownload':
                validateAdmin();
                chat.autoDownload = isEnable;
                break;
            // Add similar blocks for other cases ...
            case 'text':
                validateAdmin();
                chat.teks = isEnable;
                break;
            // ...
            default:
                return conn.adReply(m.chat, caption, wish() + ' ' + name, '', fs.readFileSync('./media/thumbnail.jpg'), '', m);
        }
        await m.reply(`${type} berhasil ${isEnable ? 'dinyalakan' : 'dimatikan'} untuk ${isAll ? 'bot ini' : 'chat ini'}!`);
    };
    
    handler.help = ['enable <command>'];
    handler.tags = ['group', 'adminry'];
    handler.command = /^((en|dis)able|setting|settings|(tru|fals)e|(turn)?o(n|ff)|[01])$/i;
    
    export default handler;
    
    function wish() {
        const time = moment.tz('Asia/Jakarta').format('HH');
        if (time >= 0 && time < 4) return 'Selamat Malam';
        if (time >= 4 && time < 11) return 'Selamat Pagi';
        if (time >= 11 && time < 15) return 'Selamat Siang';
        if (time >= 15 && time < 18) return 'Selamat Sore';
        return 'Selamat Malam';
    }
    

    Changes Made:

    1. Command Argument Handling: The code now looks for the presence of an extra argument to determine whether the command is intended to enable or disable the feature. If args[1] exists and is either false, disable, off, or 0, it sets isEnable accordingly.

    2. Validation Function: A helper function validateAdmin() checks if the command issuer has the necessary permissions for group commands, reducing repetition.

    3. Caption Handling: The content related to command summaries remains unchanged but should be filled in as necessary.

    With this modification, the bot should be able to handle commands like welcome on, welcome off, enable welcome, and disable welcome, offering more versatility in how the commands can be issued.