Skip to content

Instantly share code, notes, and snippets.

@Darker935
Last active November 22, 2020 15:47
Show Gist options
  • Save Darker935/795c21e38a864e462b602bf3582e0b82 to your computer and use it in GitHub Desktop.
Save Darker935/795c21e38a864e462b602bf3582e0b82 to your computer and use it in GitHub Desktop.
if(msg.body=='!clearChats'){
//clearing ALL CHATS
msg.reply("Clearing chats !")
const chats = await client.getChats();
for (let index = 0; index < chats.length; index++) {
let chat = chats[index]
/*
UNCOMMENT IF YOU WANT CLEAR ONLY PRIVATE CHATS
if(chats[index].isGroup==false){
await chat.clearMessages(true)
console.log("Clearing ",index," chat")
}
*/
//And delete this
await chat.clearMessages(true)
}
client.sendMessage(msg.from,"All the "+index+" chats have been cleared")
}
else if (msg.body == '!chats') {
const chats = await client.getChats();
let chatG=0
let chatP=0
//console.log(chats.id.server)
let unread=0
for (let index = 0; index < chats.length; index++) {
if(chats[index].isGroup==true){
//Group Chats ++
chatG++
//Unread ++
unread = unread + chats[index].unreadCount
}
if(chats[index].isGroup==false){
//Private Chats ++
chatP++
//Unread ++
unread = unread + chats[index].unreadCount
}
}
client.sendMessage(msg.from,
`*💬 Status* :
➣ *${unread}* unread messages
➣ *${chatG}* Groups
➣ *${chatP}* Private chats
➣ *${chats.length}* Total chats
〘Your Bot Name〙`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment