Skip to content

Commit

Permalink
Merge branch 'XM4ZE:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
NeofetchNpc authored Dec 1, 2024
2 parents ee57701 + f5add6e commit 03416b9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions plugins/gc-totalpesan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
let handler = async (m, { conn }) => {
const messages = conn.chats[m.chat].messages;
const participantCounts = {};
Object.values(messages).forEach(({ key }) =>
participantCounts[key.participant] = (participantCounts[key.participant] || 0) + 1
);
const sortedData = Object.entries(participantCounts)
.sort((a, b) => b[1] - a[1]);
const totalM = sortedData.reduce((acc, [, total]) => acc + total, 0);
const totalPeople = sortedData.length;
const pesan = sortedData
.map(([jid, total], index) => `*${index + 1}.* ${jid.replace(/(\d+)@.+/, '@$1')}: *${total}* pesan`)
.join('\n');
await m.reply(
`*Total Pesan Terakhir*: *${totalM}* pesan dari *${totalPeople}* orang\n\n${pesan}`,
null,
{
contextInfo: {
mentionedJid: sortedData.map(([jid]) => jid)
}
}
);
}
handler.help = ['totalpesan'];
handler.tags = ['group'];
handler.command = /^(totalpesan)$/i;
handler.group = true;

export default handler;

0 comments on commit 03416b9

Please sign in to comment.