forked from Keithkeizzah/KEITH-MD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
groupEvents.js
69 lines (59 loc) · 2.65 KB
/
groupEvents.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const events = process.env.EVENTS || 'false';
const botname = process.env.BOTNAME || 'KEITH-MD';
const Events = async (client, Fortu) => {
const Myself = await client.decodeJid(client.user.id);
try {
let metadata = await client.groupMetadata(Fortu.id);
let participants = Fortu.participants;
let desc = metadata.desc || "No Description";
for (let num of participants) {
let dpuser;
try {
dpuser = await client.profilePictureUrl(num, "image");
} catch {
dpuser = "https://i.imgur.com/iEWHnOH.jpeg";
}
if (Fortu.action == "add") {
let userName = num;
let Welcometext = ` Hey @${userName.split("@")[0]} 👋\n\nWelcome to ${metadata.subject}.\n\nyou may read the group Description to avoid being removed ${desc}\n\n*Regards keithkeizzah*.\n\nPowered by ${botname} .`;
if (events === 'true') {
await client.sendMessage(Fortu.id, {
image: { url: dpuser },
caption: Welcometext,
mentions: [num],
});
}
} else if (Fortu.action == "remove") {
let userName2 = num;
let Lefttext = `
Goodbye to this idiot @${userName2.split("@")[0]} you will be highly remembered comrade🖕 `;
if (events === 'true') {
await client.sendMessage(Fortu.id, {
image: { url: dpuser },
caption: Lefttext,
mentions: [num],
});
}
} else if (Fortu.action == "demote" && events === 'true') {
await client.sendMessage(
Fortu.id,
{
text: `@${(Fortu.author).split("@")[0]}, has demoted @${(Fortu.participants[0]).split("@")[0]} from admin 👀`,
mentions: [Fortu.author, Fortu.participants[0]]
}
);
} else if (Fortu.action == "promote" && events === 'true') {
await client.sendMessage(
Fortu.id,
{
text: `@${(Fortu.author).split("@")[0]} has promoted @${(Fortu.participants[0]).split("@")[0]} to admin. 👀`,
mentions: [Fortu.author, Fortu.participants[0]]
}
);
}
}
} catch (err) {
console.log(err);
}
};
module.exports = Events;