Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leave Gc #314

Merged
merged 9 commits into from
Apr 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions plugins/group-leavegc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
let handler = async (m, { conn, args, command }) => {
let chat = Object.keys(conn.chats).filter(v => v.endsWith('g.us'))
if (command.endsWith('all') || command.endsWith('semua')) {
for (let id of chat) { // perulangan
await conn.groupLeave(id)
await delay(2000) // jeda 2 detik
}
await m.reply('Berhasil!')
} else if (args[0] || args.length > 5) {
let ada = chat.find(bot => bot == args[0]) // Apakah botnya ada disitu
if (!ada) throw 'id salah/bot tidak ada digrup itu'
await conn.groupLeave(args[0])
await m.reply('Berhasil!')
} else {
if (!m.isGroup) return global.dfail('group', m, conn)
await conn.groupLeave(m.chat)
}

}

handler.help = ['gc', 'gcall', 'group'].map(v => 'leave' + v)
handler.tags = ['group']
handler.command = /^leaveg(c|ro?up)(all|semua)?$/i

handler.rowner = true

export default handler

const delay = time => new Promise(res => setTimeout(res, time))