Skip to content

Commit

Permalink
Update haki.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hakisolos authored Jan 1, 2025
1 parent f45836f commit 5442a65
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions haki.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,33 +151,35 @@ async function Abhiy() {
try {
conn.ev.on("creds.update", saveCreds);

conn.ev.removeAllListeners("group-participants.update"); // Prevent duplicate listeners
conn.ev.removeAllListeners("group-participants.update");
conn.ev.on("group-participants.update", async (data) => {
try {
const metadata = await conn.groupMetadata(data.id); // Fetch group metadata
const metadata = await conn.groupMetadata(data.id);
const groupName = metadata.subject;

if (data.action === "add") {
for (const participant of data.participants) {
const ppUrl = await conn.profilePictureUrl(participant, "image").catch(() => null);
const welcomeMessage = `Hello @${participant.split("@")[0]}, welcome to *${groupName}*! 🎉\nFeel free to introduce yourself and enjoy your stay.`;

await conn.sendMessage(data.id, {
image: { url: ppUrl || "https://files.catbox.moe/placeholder.png" }, // Fallback image
caption: welcomeMessage,
mentions: [participant],
});
}
} else if (data.action === "remove") {
for (const participant of data.participants) {
const ppUrl = await conn.profilePictureUrl(participant, "image").catch(() => null);
const goodbyeMessage = `Goodbye @${participant.split("@")[0]}, we’ll miss you from *${groupName}*. 😢`;

await conn.sendMessage(data.id, {
image: { url: ppUrl || "https://files.catbox.moe/placeholder.png" }, // Fallback image
caption: goodbyeMessage,
mentions: [participant],
});
if (config.GREETINGS) {
if (data.action === "add") {
for (const participant of data.participants) {
const ppUrl = await conn.profilePictureUrl(participant, "image").catch(() => null);
const welcomeMessage = `Hello @${participant.split("@")[0]}, welcome to *${groupName}*! 🎉\nFeel free to introduce yourself and enjoy your stay.`;

await conn.sendMessage(data.id, {
image: { url: ppUrl || "https://files.catbox.moe/placeholder.png" },
caption: welcomeMessage,
mentions: [participant],
});
}
} else if (data.action === "remove") {
for (const participant of data.participants) {
const ppUrl = await conn.profilePictureUrl(participant, "image").catch(() => null);
const goodbyeMessage = `Goodbye @${participant.split("@")[0]}, we’ll miss you from *${groupName}*. 😢`;

await conn.sendMessage(data.id, {
image: { url: ppUrl || "https://files.catbox.moe/placeholder.png" },
caption: goodbyeMessage,
mentions: [participant],
});
}
}
}
} catch (error) {
Expand Down

0 comments on commit 5442a65

Please sign in to comment.