-
-
Save esteves67/e5c4a0c75087bdae9d9616d29037932d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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