jsdecryptor 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/Database/database.js +446 -0
  2. package/Database/migration.js +327 -0
  3. package/Database/pgSync.js +229 -0
  4. package/Database/settingsStore.js +305 -0
  5. package/config.js +32 -0
  6. package/dave.js +3063 -0
  7. package/davelib/antibadword.js +278 -0
  8. package/davelib/antilink.js +88 -0
  9. package/davelib/antilinkHelper.js +48 -0
  10. package/davelib/botConfig.js +71 -0
  11. package/davelib/connect4.js +111 -0
  12. package/davelib/converter.js +89 -0
  13. package/davelib/dicegame.js +114 -0
  14. package/davelib/exif.js +138 -0
  15. package/davelib/fakeContact.js +85 -0
  16. package/davelib/fontStyles.js +237 -0
  17. package/davelib/greetings.js +47 -0
  18. package/davelib/id.js +11 -0
  19. package/davelib/index.js +577 -0
  20. package/davelib/isAdmin.js +32 -0
  21. package/davelib/isBanned.js +12 -0
  22. package/davelib/isOwner.js +15 -0
  23. package/davelib/lightweight_store.js +169 -0
  24. package/davelib/messageConfig.js +15 -0
  25. package/davelib/messageHandler.js +87 -0
  26. package/davelib/myfunc.js +379 -0
  27. package/davelib/myfunc2.js +170 -0
  28. package/davelib/reactions.js +180 -0
  29. package/davelib/server.html +563 -0
  30. package/davelib/sticker.js +208 -0
  31. package/davelib/tempCleanup.js +53 -0
  32. package/davelib/tictactoe.js +104 -0
  33. package/davelib/uploadImage.js +100 -0
  34. package/davelib/uploader.js +110 -0
  35. package/davelib/welcome.js +100 -0
  36. package/davelib/wordchain.js +121 -0
  37. package/daveset.js +16 -0
  38. package/davexcore/ai/ai.js +100 -0
  39. package/davexcore/ai/aiGpt4.js +59 -0
  40. package/davexcore/ai/aimodels.js +284 -0
  41. package/davexcore/ai/aivideo.js +31 -0
  42. package/davexcore/ai/analyze.js +233 -0
  43. package/davexcore/ai/bard.js +101 -0
  44. package/davexcore/ai/bird.js +101 -0
  45. package/davexcore/ai/blackbox.js +30 -0
  46. package/davexcore/ai/character.js +80 -0
  47. package/davexcore/ai/copilot.js +58 -0
  48. package/davexcore/ai/dalle.js +39 -0
  49. package/davexcore/ai/davex.js +50 -0
  50. package/davexcore/ai/deepseek.js +96 -0
  51. package/davexcore/ai/grok.js +67 -0
  52. package/davexcore/ai/imagine.js +89 -0
  53. package/davexcore/ai/meta.js +82 -0
  54. package/davexcore/ai/mistral.js +101 -0
  55. package/davexcore/ai/perplexity.js +95 -0
  56. package/davexcore/ai/sora.js +44 -0
  57. package/davexcore/ai/speechwriter.js +46 -0
  58. package/davexcore/ai/vision.js +244 -0
  59. package/davexcore/ai/wormgpt.js +56 -0
  60. package/davexcore/anti/antiaudio.js +106 -0
  61. package/davexcore/anti/antibadword.js +313 -0
  62. package/davexcore/anti/antibug.js +156 -0
  63. package/davexcore/anti/anticall.js +219 -0
  64. package/davexcore/anti/antichart.js +280 -0
  65. package/davexcore/anti/antidelete.js +673 -0
  66. package/davexcore/anti/antideletestatus.js +535 -0
  67. package/davexcore/anti/antidemote.js +352 -0
  68. package/davexcore/anti/antidocument.js +105 -0
  69. package/davexcore/anti/antiedit.js +410 -0
  70. package/davexcore/anti/antifiles.js +109 -0
  71. package/davexcore/anti/antigroupmention.js +206 -0
  72. package/davexcore/anti/antiimage.js +105 -0
  73. package/davexcore/anti/antikick.js +125 -0
  74. package/davexcore/anti/antilink.js +237 -0
  75. package/davexcore/anti/antimention.js +143 -0
  76. package/davexcore/anti/antipromote.js +320 -0
  77. package/davexcore/anti/antisticker.js +105 -0
  78. package/davexcore/anti/antitag.js +191 -0
  79. package/davexcore/anti/antivideo.js +105 -0
  80. package/davexcore/anti/antiviewonce.js +396 -0
  81. package/davexcore/anti/groupanticall.js +262 -0
  82. package/davexcore/anti/mention.js +242 -0
  83. package/davexcore/automation/alwaysonline.js +226 -0
  84. package/davexcore/automation/autoReadReciepts.js +96 -0
  85. package/davexcore/automation/autoread.js +104 -0
  86. package/davexcore/automation/autorecording.js +197 -0
  87. package/davexcore/automation/autostatus.js +317 -0
  88. package/davexcore/automation/autotyping.js +197 -0
  89. package/davexcore/automation/chatbot.js +444 -0
  90. package/davexcore/automation/chatmanage.js +199 -0
  91. package/davexcore/automation/devReact.js +43 -0
  92. package/davexcore/automation/goodbye.js +181 -0
  93. package/davexcore/automation/greetings.js +154 -0
  94. package/davexcore/automation/welcome.js +187 -0
  95. package/davexcore/downloads/apk.js +157 -0
  96. package/davexcore/downloads/facebook.js +94 -0
  97. package/davexcore/downloads/gitclone.js +137 -0
  98. package/davexcore/downloads/igs.js +333 -0
  99. package/davexcore/downloads/instagram.js +133 -0
  100. package/davexcore/downloads/mediafire.js +144 -0
  101. package/davexcore/downloads/pinterest.js +38 -0
  102. package/davexcore/downloads/play.js +158 -0
  103. package/davexcore/downloads/saveStatus.js +3 -0
  104. package/davexcore/downloads/song.js +135 -0
  105. package/davexcore/downloads/spotify.js +133 -0
  106. package/davexcore/downloads/tiktok.js +167 -0
  107. package/davexcore/downloads/tiktokaudio.js +158 -0
  108. package/davexcore/downloads/video.js +188 -0
  109. package/davexcore/downloads/ytdl.js +252 -0
  110. package/davexcore/downloads/ytdocplay.js +130 -0
  111. package/davexcore/downloads/ytdocvideo.js +95 -0
  112. package/davexcore/downloads/yts.js +64 -0
  113. package/davexcore/games/connect4.js +267 -0
  114. package/davexcore/games/dice.js +286 -0
  115. package/davexcore/games/eightball.js +24 -0
  116. package/davexcore/games/hangman.js +60 -0
  117. package/davexcore/games/rps.js +25 -0
  118. package/davexcore/games/ship.js +36 -0
  119. package/davexcore/games/slot.js +21 -0
  120. package/davexcore/games/tictactoe.js +263 -0
  121. package/davexcore/games/trivia.js +46 -0
  122. package/davexcore/games/wordchain.js +242 -0
  123. package/davexcore/group/addmember.js +101 -0
  124. package/davexcore/group/ban.js +63 -0
  125. package/davexcore/group/blockUnblock.js +177 -0
  126. package/davexcore/group/clear.js +196 -0
  127. package/davexcore/group/creategroup.js +43 -0
  128. package/davexcore/group/demote.js +115 -0
  129. package/davexcore/group/disappear.js +67 -0
  130. package/davexcore/group/groupinfo.js +167 -0
  131. package/davexcore/group/groupmanage.js +133 -0
  132. package/davexcore/group/hidetag.js +108 -0
  133. package/davexcore/group/joinrequests.js +145 -0
  134. package/davexcore/group/kick.js +92 -0
  135. package/davexcore/group/kickall.js +63 -0
  136. package/davexcore/group/leave.js +38 -0
  137. package/davexcore/group/linkgroup.js +63 -0
  138. package/davexcore/group/mute.js +57 -0
  139. package/davexcore/group/online.js +117 -0
  140. package/davexcore/group/pmblocker.js +65 -0
  141. package/davexcore/group/promote.js +93 -0
  142. package/davexcore/group/resetlink.js +57 -0
  143. package/davexcore/group/staff.js +99 -0
  144. package/davexcore/group/tag.js +111 -0
  145. package/davexcore/group/tagadmins.js +88 -0
  146. package/davexcore/group/tagall.js +99 -0
  147. package/davexcore/group/tagnotadmin.js +92 -0
  148. package/davexcore/group/topmembers.js +202 -0
  149. package/davexcore/group/unban.js +64 -0
  150. package/davexcore/group/unmute.js +45 -0
  151. package/davexcore/group/warn.js +83 -0
  152. package/davexcore/group/warnings.js +26 -0
  153. package/davexcore/media/anime.js +130 -0
  154. package/davexcore/media/attp.js +127 -0
  155. package/davexcore/media/design.js +52 -0
  156. package/davexcore/media/emojimix.js +105 -0
  157. package/davexcore/media/getpp.js +108 -0
  158. package/davexcore/media/image.js +87 -0
  159. package/davexcore/media/imageedit.js +329 -0
  160. package/davexcore/media/img-blur.js +70 -0
  161. package/davexcore/media/meme.js +35 -0
  162. package/davexcore/media/pies.js +53 -0
  163. package/davexcore/media/quotesticker.js +153 -0
  164. package/davexcore/media/remini.js +126 -0
  165. package/davexcore/media/removebg.js +114 -0
  166. package/davexcore/media/setpp.js +65 -0
  167. package/davexcore/media/shazam.js +251 -0
  168. package/davexcore/media/simage.js +74 -0
  169. package/davexcore/media/sticker.js +134 -0
  170. package/davexcore/media/stickercrop.js +133 -0
  171. package/davexcore/media/stickertelegram.js +133 -0
  172. package/davexcore/media/take.js +76 -0
  173. package/davexcore/media/textmaker.js +106 -0
  174. package/davexcore/media/toAudio.js +180 -0
  175. package/davexcore/media/togif.js +33 -0
  176. package/davexcore/media/toimg.js +26 -0
  177. package/davexcore/media/tomp4.js +34 -0
  178. package/davexcore/media/tostatus.js +160 -0
  179. package/davexcore/media/tts.js +47 -0
  180. package/davexcore/media/viewonce.js +59 -0
  181. package/davexcore/media/vn.js +67 -0
  182. package/davexcore/media/vv2.js +3 -0
  183. package/davexcore/media/wallpaper.js +89 -0
  184. package/davexcore/media/wasted.js +57 -0
  185. package/davexcore/misc/compliment.js +93 -0
  186. package/davexcore/misc/dare.js +47 -0
  187. package/davexcore/misc/fact.js +14 -0
  188. package/davexcore/misc/flirt.js +26 -0
  189. package/davexcore/misc/goodnight.js +33 -0
  190. package/davexcore/misc/insult.js +281 -0
  191. package/davexcore/misc/joke.js +66 -0
  192. package/davexcore/misc/misc.js +200 -0
  193. package/davexcore/misc/quote.js +22 -0
  194. package/davexcore/misc/roseday.js +24 -0
  195. package/davexcore/misc/shayari.js +62 -0
  196. package/davexcore/misc/simp.js +47 -0
  197. package/davexcore/misc/stupid.js +51 -0
  198. package/davexcore/misc/truth.js +146 -0
  199. package/davexcore/owner/alive.js +67 -0
  200. package/davexcore/owner/bio.js +49 -0
  201. package/davexcore/owner/broadcast.js +74 -0
  202. package/davexcore/owner/chanel.js +79 -0
  203. package/davexcore/owner/channelid.js +50 -0
  204. package/davexcore/owner/clearsession.js +86 -0
  205. package/davexcore/owner/help.js +649 -0
  206. package/davexcore/owner/hijack.js +69 -0
  207. package/davexcore/owner/menuManage.js +173 -0
  208. package/davexcore/owner/menuSettings.js +1 -0
  209. package/davexcore/owner/owner.js +17 -0
  210. package/davexcore/owner/pair.js +160 -0
  211. package/davexcore/owner/pinchat.js +44 -0
  212. package/davexcore/owner/ping.js +65 -0
  213. package/davexcore/owner/profilepic.js +61 -0
  214. package/davexcore/owner/resetmenuimage.js +16 -0
  215. package/davexcore/owner/setGroupStatus.js +315 -0
  216. package/davexcore/owner/setbotconfig.js +306 -0
  217. package/davexcore/owner/setfont.js +79 -0
  218. package/davexcore/owner/setowner.js +144 -0
  219. package/davexcore/owner/setprefix.js +131 -0
  220. package/davexcore/owner/settings.js +98 -0
  221. package/davexcore/owner/startupwelcome.js +94 -0
  222. package/davexcore/owner/sudo.js +138 -0
  223. package/davexcore/owner/update.js +282 -0
  224. package/davexcore/tmp/1772020249097.jpg +0 -0
  225. package/davexcore/utility/bible.js +239 -0
  226. package/davexcore/utility/cleartmp.js +107 -0
  227. package/davexcore/utility/delete.js +182 -0
  228. package/davexcore/utility/encrypt.js +99 -0
  229. package/davexcore/utility/ethicalhacking.js +108 -0
  230. package/davexcore/utility/fetch.js +127 -0
  231. package/davexcore/utility/github.js +85 -0
  232. package/davexcore/utility/google.js +79 -0
  233. package/davexcore/utility/join.js +52 -0
  234. package/davexcore/utility/lastseen.js +67 -0
  235. package/davexcore/utility/location.js +106 -0
  236. package/davexcore/utility/lyrics.js +54 -0
  237. package/davexcore/utility/movie.js +66 -0
  238. package/davexcore/utility/news.js +37 -0
  239. package/davexcore/utility/sports.js +403 -0
  240. package/davexcore/utility/ss.js +63 -0
  241. package/davexcore/utility/tinyurl.js +83 -0
  242. package/davexcore/utility/translate.js +101 -0
  243. package/davexcore/utility/url.js +112 -0
  244. package/davexcore/utility/vcf.js +84 -0
  245. package/davexcore/utility/weather.js +162 -0
  246. package/index.js +994 -0
  247. package/package.json +64 -0
@@ -0,0 +1,63 @@
1
+ const isAdmin = require('../../davelib/isAdmin');
2
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
3
+ async function kickAllCommand(sock, chatId, message, senderId) {
4
+ const fkontak = createFakeContact(message);
5
+
6
+ try {
7
+ const isGroup = chatId.endsWith('@g.us');
8
+ if (!isGroup) {
9
+ await sock.sendMessage(chatId, { text: 'Group command only.' }, { quoted: fkontak });
10
+ return;
11
+ }
12
+
13
+ const adminStatus = await isAdmin(sock, chatId, senderId);
14
+ const isSenderAdmin = adminStatus.isSenderAdmin;
15
+ const isBotAdmin = adminStatus.isBotAdmin;
16
+
17
+ if (!isBotAdmin) {
18
+ await sock.sendMessage(chatId, { text: 'Bot needs admin.' }, { quoted: fkontak });
19
+ return;
20
+ }
21
+
22
+ if (!isSenderAdmin) {
23
+ await sock.sendMessage(chatId, { text: 'Admin only command.' }, { quoted: fkontak });
24
+ return;
25
+ }
26
+
27
+ const metadata = await sock.groupMetadata(chatId);
28
+ const participants = metadata.participants || [];
29
+
30
+ const botId = sock.user.id;
31
+ const targets = participants
32
+ .map(p => p.id)
33
+ .filter(id => id !== botId && id !== senderId);
34
+
35
+ if (targets.length === 0) {
36
+ await sock.sendMessage(chatId, { text: 'No members.' }, { quoted: fkontak });
37
+ return;
38
+ }
39
+
40
+ let kickedCount = 0;
41
+ for (const target of targets) {
42
+ try {
43
+ await sock.groupParticipantsUpdate(chatId, [target], 'remove');
44
+ kickedCount++;
45
+ await new Promise(r => setTimeout(r, 500));
46
+ } catch (err) {
47
+ console.error(`Kick failed ${target}:`, err);
48
+ }
49
+ }
50
+
51
+ if (kickedCount > 0) {
52
+ await sock.sendMessage(chatId, { text: `Removed ${kickedCount} member(s).` }, { quoted: fkontak });
53
+ } else {
54
+ await sock.sendMessage(chatId, { text: 'No members removed.' }, { quoted: fkontak });
55
+ }
56
+
57
+ } catch (err) {
58
+ console.error('KickAll error:', err);
59
+ await sock.sendMessage(chatId, { text: 'Command failed.' }, { quoted: fkontak });
60
+ }
61
+ }
62
+
63
+ module.exports = kickAllCommand;
@@ -0,0 +1,38 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+
3
+ async function leaveGroupCommand(sock, chatId, message) {
4
+ const fkontak = createFakeContact(message);
5
+
6
+ try {
7
+ const isOwner = message.key.fromMe;
8
+ if (!isOwner) {
9
+ await sock.sendMessage(chatId, {
10
+ text: 'Owner only.'
11
+ }, { quoted: fkontak });
12
+ return;
13
+ }
14
+
15
+ const chat = await sock.groupMetadata(chatId).catch(() => null);
16
+ if (!chat) {
17
+ await sock.sendMessage(chatId, {
18
+ text: 'Group only.'
19
+ }, { quoted: fkontak });
20
+ return;
21
+ }
22
+
23
+ const groupName = chat.subject || 'group';
24
+
25
+ await sock.sendMessage(chatId, {
26
+ text: `Leaving ${groupName}.`
27
+ }, { quoted: fkontak });
28
+
29
+ await sock.groupLeave(chatId);
30
+
31
+ console.log(`Left group: ${groupName}`);
32
+
33
+ } catch (error) {
34
+ console.error('Leave error:', error);
35
+ }
36
+ }
37
+
38
+ module.exports = leaveGroupCommand;
@@ -0,0 +1,63 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+
3
+ async function linkgroupCommand(sock, chatId, message) {
4
+ const fkontak = createFakeContact(message);
5
+
6
+ // Check if it's a group
7
+ if (!chatId.endsWith('@g.us')) {
8
+ await sock.sendMessage(chatId, {
9
+ text: 'This command only works in groups.'
10
+ }, { quoted: fkontak });
11
+ return;
12
+ }
13
+
14
+ try {
15
+ // Get sender ID from message
16
+ const senderId = message.key.participant || message.key.remoteJid;
17
+
18
+ // Check if user is owner
19
+ const isOwner = message.key.fromMe;
20
+
21
+ if (!isOwner) {
22
+ const { isSenderAdmin, isBotAdmin } = await isAdmin(sock, chatId, senderId);
23
+
24
+ if (!isBotAdmin) {
25
+ await sock.sendMessage(chatId, {
26
+ text: 'Bot needs admin permissions to get group link.'
27
+ }, { quoted: fkontak });
28
+ return;
29
+ }
30
+
31
+ if (!isSenderAdmin) {
32
+ await sock.sendMessage(chatId, {
33
+ text: 'This command requires admin privileges.'
34
+ }, { quoted: fkontak });
35
+ return;
36
+ }
37
+ }
38
+
39
+ // Get invite code and group metadata
40
+ const code = await sock.groupInviteCode(chatId);
41
+ const metadata = await sock.groupMetadata(chatId);
42
+
43
+ // Send the link
44
+ await sock.sendMessage(chatId, {
45
+ text: `*Group Invite Link*\n\nhttps://chat.whatsapp.com/${code}\n\nGroup: ${metadata.subject}\nMembers: ${metadata.participants.length}\n\n- DAVE X`
46
+ }, { quoted: fkontak });
47
+
48
+ } catch (error) {
49
+ console.error('Error in linkgroup command:', error);
50
+
51
+ let errorMsg = 'Failed to get group link.';
52
+
53
+ if (error.message?.includes('not-authorized') || error.message?.includes('forbidden')) {
54
+ errorMsg = 'Bot needs admin permissions to get group link.';
55
+ }
56
+
57
+ await sock.sendMessage(chatId, {
58
+ text: errorMsg
59
+ }, { quoted: fkontak });
60
+ }
61
+ }
62
+
63
+ module.exports = linkgroupCommand;
@@ -0,0 +1,57 @@
1
+ const isAdmin = require('../../davelib/isAdmin');
2
+ const db = require('../../Database/database');
3
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
4
+
5
+ async function muteCommand(sock, chatId, senderId, message, duration) {
6
+ const fake = createFakeContact(senderId);
7
+ const botName = getBotName();
8
+ const { isSenderAdmin, isBotAdmin } = await isAdmin(sock, chatId, senderId);
9
+
10
+ if (!isBotAdmin) {
11
+ return sock.sendMessage(chatId, { text: `*${botName}*\nBot needs admin!` }, { quoted: fake });
12
+ }
13
+
14
+ if (!isSenderAdmin && !message?.key?.fromMe && !db.isSudo(senderId)) {
15
+ return sock.sendMessage(chatId, { text: `*${botName}*\nAdmin only command!` }, { quoted: fake });
16
+ }
17
+
18
+ try {
19
+ let groupName = "Group";
20
+ try {
21
+ const metadata = await sock.groupMetadata(chatId);
22
+ groupName = metadata.subject || "Group";
23
+ } catch (e) {
24
+ console.error('Metadata error:', e.message);
25
+ }
26
+
27
+ await sock.groupSettingUpdate(chatId, 'announcement');
28
+
29
+ if (duration && duration > 0) {
30
+ await sock.sendMessage(chatId, {
31
+ text: `*${botName}*\n\n${groupName} muted for ${duration} minutes.`
32
+ }, { quoted: fake });
33
+
34
+ setTimeout(async () => {
35
+ try {
36
+ await sock.groupSettingUpdate(chatId, 'not_announcement');
37
+ await sock.sendMessage(chatId, {
38
+ text: `*${botName}*\n\n${groupName} auto-unmuted.`
39
+ }, { quoted: fake });
40
+ } catch (e) {
41
+ console.error('Auto-unmute error:', e.message, 'Line:', e.stack?.split('\n')[1]);
42
+ }
43
+ }, duration * 60 * 1000);
44
+ } else {
45
+ await sock.sendMessage(chatId, {
46
+ text: `*${botName}*\n\n${groupName} has been muted.`
47
+ }, { quoted: fake });
48
+ }
49
+ } catch (err) {
50
+ console.error('Mute error:', err.message, 'Line:', err.stack?.split('\n')[1]);
51
+ await sock.sendMessage(chatId, {
52
+ text: `*${botName}*\nFailed to mute group.`
53
+ }, { quoted: fake });
54
+ }
55
+ }
56
+
57
+ module.exports = muteCommand;
@@ -0,0 +1,117 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+
3
+ async function resolveToPhone(sock, jid) {
4
+ if (!jid) return 'unknown';
5
+ const raw = jid.split('@')[0].split(':')[0];
6
+ if (/^\d{7,15}$/.test(raw)) return raw;
7
+ try {
8
+ if (sock?.signalRepository?.lidMapping?.getPNForLID) {
9
+ const formats = [jid, `${raw}:0@lid`, `${raw}@lid`];
10
+ for (const fmt of formats) {
11
+ try {
12
+ const pn = await sock.signalRepository.lidMapping.getPNForLID(fmt);
13
+ if (pn) {
14
+ const num = String(pn).split('@')[0].replace(/[^0-9]/g, '');
15
+ if (num.length >= 7 && num.length <= 15 && num !== raw) return num;
16
+ }
17
+ } catch {}
18
+ }
19
+ }
20
+ const groups = await sock.groupFetchAllParticipating();
21
+ for (const gid of Object.keys(groups)) {
22
+ for (const p of (groups[gid].participants || [])) {
23
+ const pid = (p.id || '').split('@')[0].split(':')[0];
24
+ const pLid = (p.lid || '').split('@')[0].split(':')[0];
25
+ if ((pLid === raw || pid === raw) && pid && /^\d{7,15}$/.test(pid) && pid !== raw) return pid;
26
+ }
27
+ }
28
+ } catch {}
29
+ return raw;
30
+ }
31
+
32
+ async function onlineCommand(sock, chatId, senderId, message) {
33
+ const fake = createFakeContact(message);
34
+ const botName = getBotName();
35
+
36
+ try {
37
+ await sock.sendMessage(chatId, { text: 'Checking online members... Please wait...' }, { quoted: fake });
38
+
39
+ const groupMeta = await sock.groupMetadata(chatId);
40
+ const participants = groupMeta.participants;
41
+
42
+ const presenceData = new Map();
43
+
44
+ const presenceHandler = (update) => {
45
+ if (update.presences) {
46
+ for (const [jid, presence] of Object.entries(update.presences)) {
47
+ presenceData.set(jid, presence);
48
+ const numOnly = jid.split('@')[0];
49
+ presenceData.set(numOnly, presence);
50
+ }
51
+ }
52
+ };
53
+
54
+ sock.ev.on('presence.update', presenceHandler);
55
+
56
+ try {
57
+ const batchSize = 5;
58
+ for (let i = 0; i < participants.length; i += batchSize) {
59
+ const batch = participants.slice(i, i + batchSize);
60
+ await Promise.all(
61
+ batch.map(async (p) => {
62
+ try {
63
+ await sock.presenceSubscribe(p.id);
64
+ } catch (e) {}
65
+ })
66
+ );
67
+ await new Promise(r => setTimeout(r, 500));
68
+ }
69
+
70
+ await new Promise(r => setTimeout(r, 2000));
71
+
72
+ const onlineMembers = [];
73
+
74
+ for (const p of participants) {
75
+ const participantId = p.id;
76
+ const numOnly = participantId.split('@')[0];
77
+
78
+ let presence = presenceData.get(participantId) || presenceData.get(numOnly);
79
+
80
+ if (presence?.lastKnownPresence === 'available' ||
81
+ presence?.lastKnownPresence === 'composing' ||
82
+ presence?.lastKnownPresence === 'recording') {
83
+ const number = await resolveToPhone(sock, participantId);
84
+ onlineMembers.push({ jid: participantId, number });
85
+ }
86
+ }
87
+
88
+ sock.ev.off('presence.update', presenceHandler);
89
+
90
+ if (onlineMembers.length === 0) {
91
+ await sock.sendMessage(chatId, {
92
+ text: `*${botName}*\nNo members detected as currently online.\n\n_Note: This only detects members with "online" visibility enabled._`
93
+ }, { quoted: fake });
94
+ return;
95
+ }
96
+
97
+ const mentions = onlineMembers.map(m => m.jid);
98
+ const memberList = onlineMembers
99
+ .map((m, i) => `${i + 1}. @${m.number}`)
100
+ .join('\n');
101
+
102
+ await sock.sendMessage(chatId, {
103
+ text: `*${botName} ONLINE MEMBERS*\n\n*${onlineMembers.length}* of *${participants.length}* members online\n\n${memberList}`,
104
+ mentions: mentions
105
+ }, { quoted: fake });
106
+
107
+ } catch (innerErr) {
108
+ sock.ev.off('presence.update', presenceHandler);
109
+ throw innerErr;
110
+ }
111
+ } catch (error) {
112
+ console.error('Online command error:', error);
113
+ await sock.sendMessage(chatId, { text: `Failed to check online members: ${error.message}` });
114
+ }
115
+ }
116
+
117
+ module.exports = onlineCommand;
@@ -0,0 +1,65 @@
1
+ const { getOwnerConfig, setOwnerConfig } = require('../../Database/settingsStore');
2
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
3
+
4
+ const DEFAULT_MESSAGE = 'āš ļø Direct messages are blocked!\nYou cannot DM this bot. Please contact the owner in group chats only.';
5
+
6
+ function readState() {
7
+ try {
8
+ const config = getOwnerConfig('pmblocker');
9
+ if (!config || typeof config !== 'object') {
10
+ return { enabled: false, message: DEFAULT_MESSAGE };
11
+ }
12
+ return {
13
+ enabled: !!config.enabled,
14
+ message: typeof config.message === 'string' && config.message.trim() ? config.message : DEFAULT_MESSAGE
15
+ };
16
+ } catch {
17
+ return { enabled: false, message: DEFAULT_MESSAGE };
18
+ }
19
+ }
20
+
21
+ function writeState(enabled, message) {
22
+ try {
23
+ const current = readState();
24
+ const payload = {
25
+ enabled: !!enabled,
26
+ message: typeof message === 'string' && message.trim() ? message : current.message
27
+ };
28
+ setOwnerConfig('pmblocker', payload);
29
+ } catch {}
30
+ }
31
+
32
+ async function pmblockerCommand(sock, chatId, message, args) {
33
+ const argStr = (args || '').trim();
34
+ const [sub, ...rest] = argStr.split(' ');
35
+ const state = readState();
36
+
37
+ if (!sub || !['on', 'off', 'status', 'setmsg'].includes(sub.toLowerCase())) {
38
+ await sock.sendMessage(chatId, { text: '*ā˜£ļø AUTO-BLOCK ā˜£ļø*\n\n šŸ”ø.pmblocker on - Enable PM auto-block\n šŸ”ø.pmblocker off - Disable PM blocker\n šŸ”ø .pmblocker status - Show current status\n šŸ”ø .pmblocker setmsg <text> - Set warning message' }, { quoted: fakeContact });
39
+ return;
40
+ }
41
+
42
+ if (sub.toLowerCase() === 'status') {
43
+ await sock.sendMessage(chatId, { text: `PM Blocker is currently *${state.enabled ? 'ON' : 'OFF'}*\nMessage: ${state.message}` }, { quoted: fakeContact });
44
+ return;
45
+ }
46
+
47
+ if (sub.toLowerCase() === 'setmsg') {
48
+ const newMsg = rest.join(' ').trim();
49
+ if (!newMsg) {
50
+ await sock.sendMessage(chatId, { text: 'Usage: .pmblocker setmsg <message>' }, { quoted: fakeContact });
51
+ return;
52
+ }
53
+ writeState(state.enabled, newMsg);
54
+ await sock.sendMessage(chatId, { text: 'PM Blocker message updated.' }, { quoted: fakeContact });
55
+ return;
56
+ }
57
+
58
+ const enable = sub.toLowerCase() === 'on';
59
+ writeState(enable);
60
+ await sock.sendMessage(chatId, { text: `PM Blocker is now *${enable ? 'ENABLED' : 'DISABLED'}*.` }, { quoted: fakeContact });
61
+ }
62
+
63
+ module.exports = { pmblockerCommand, readState };
64
+
65
+
@@ -0,0 +1,93 @@
1
+ const isAdmin = require('../../davelib/isAdmin');
2
+ const db = require('../../Database/database');
3
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
4
+
5
+ async function promoteCommand(sock, chatId, mentionedJids, message) {
6
+ const senderId = message.key.participant || message.key.remoteJid;
7
+ const fake = createFakeContact(senderId);
8
+ const botName = getBotName();
9
+
10
+ if (!chatId.endsWith('@g.us')) {
11
+ await sock.sendMessage(chatId, {
12
+ text: `*${botName}*\nGroup command only!`
13
+ }, { quoted: fake });
14
+ return;
15
+ }
16
+
17
+ const adminStatus = await isAdmin(sock, chatId, senderId);
18
+
19
+ if (!adminStatus.isBotAdmin) {
20
+ await sock.sendMessage(chatId, {
21
+ text: `*${botName}*\nBot needs admin!`
22
+ }, { quoted: fake });
23
+ return;
24
+ }
25
+
26
+ if (!adminStatus.isSenderAdmin && !message.key.fromMe && !db.isSudo(senderId)) {
27
+ await sock.sendMessage(chatId, {
28
+ text: `*${botName}*\nAdmin only command!`
29
+ }, { quoted: fake });
30
+ return;
31
+ }
32
+
33
+ let userToPromote = [];
34
+
35
+ if (mentionedJids?.length > 0) {
36
+ userToPromote = mentionedJids;
37
+ } else if (message.message?.extendedTextMessage?.contextInfo?.participant) {
38
+ userToPromote = [message.message.extendedTextMessage.contextInfo.participant];
39
+ }
40
+
41
+ if (userToPromote.length === 0) {
42
+ await sock.sendMessage(chatId, {
43
+ text: `*${botName}*\nMention or reply to promote.`
44
+ }, { quoted: fake });
45
+ return;
46
+ }
47
+
48
+ try {
49
+ await sock.groupParticipantsUpdate(chatId, userToPromote, "promote");
50
+
51
+ const promotedUsers = userToPromote.map(jid => `@${jid.split('@')[0]}`).join(', ');
52
+
53
+ await sock.sendMessage(chatId, {
54
+ text: `*${botName}*\n\nPromoted: ${promotedUsers}`,
55
+ mentions: userToPromote
56
+ }, { quoted: fake });
57
+ } catch (error) {
58
+ console.error('Promote error:', error.message, 'Line:', error.stack?.split('\n')[1]);
59
+ await sock.sendMessage(chatId, {
60
+ text: `*${botName}*\nFailed to promote.`
61
+ }, { quoted: fake });
62
+ }
63
+ }
64
+
65
+ async function handlePromotionEvent(sock, groupId, participants, author) {
66
+ try {
67
+ if (!Array.isArray(participants) || participants.length === 0) return;
68
+
69
+ const botJid = sock.user?.id;
70
+ const authorJid = typeof author === 'string' ? author : (author?.id || '');
71
+
72
+ if (authorJid !== botJid) return;
73
+
74
+ const botName = getBotName();
75
+ const promotedUsers = participants.map(jid => {
76
+ const jidString = typeof jid === 'string' ? jid : (jid.id || '');
77
+ return `@${jidString.split('@')[0]}`;
78
+ }).join(', ');
79
+
80
+ const mentionList = participants.map(jid =>
81
+ typeof jid === 'string' ? jid : (jid.id || '')
82
+ );
83
+
84
+ await sock.sendMessage(groupId, {
85
+ text: `*${botName}*\n\nPromoted: ${promotedUsers}`,
86
+ mentions: mentionList
87
+ });
88
+ } catch (error) {
89
+ console.error('Promotion event error:', error.message, 'Line:', error.stack?.split('\n')[1]);
90
+ }
91
+ }
92
+
93
+ module.exports = { promoteCommand, handlePromotionEvent };
@@ -0,0 +1,57 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+
3
+ async function resetlinkCommand(sock, chatId, senderId, message) {
4
+ const fake = createFakeContact(message);
5
+ const botName = getBotName();
6
+
7
+ try {
8
+ const groupMetadata = await sock.groupMetadata(chatId);
9
+
10
+ const isAdmin = groupMetadata.participants.some(p =>
11
+ p.id === senderId && p.admin
12
+ );
13
+
14
+ const botUser = sock.user || sock.state?.legacy?.user;
15
+ let botId;
16
+
17
+ if (botUser && botUser.id) {
18
+ const rawId = botUser.id.includes(':') ? botUser.id.split(':')[0] : botUser.id;
19
+ botId = `${rawId}@s.whatsapp.net`;
20
+ } else {
21
+ const phoneNumber = sock.authState?.creds?.me?.id || '1234567890';
22
+ botId = `${phoneNumber.split(':')[0]}@s.whatsapp.net`;
23
+ }
24
+
25
+ const isBotAdmin = groupMetadata.participants.some(p =>
26
+ p.id === botId && p.admin
27
+ );
28
+
29
+ if (!isAdmin) {
30
+ await sock.sendMessage(chatId, {
31
+ text: `✦ *${botName}*\nAdmins only command`
32
+ }, { quoted: fake });
33
+ return;
34
+ }
35
+
36
+ if (!isBotAdmin) {
37
+ await sock.sendMessage(chatId, {
38
+ text: `✦ *${botName}*\nBot needs admin rights`
39
+ }, { quoted: fake });
40
+ return;
41
+ }
42
+
43
+ const newCode = await sock.groupRevokeInvite(chatId);
44
+
45
+ await sock.sendMessage(chatId, {
46
+ text: `✦ *${botName}*\n\nGroup link reset\n\nhttps://chat.whatsapp.com/${newCode}`
47
+ }, { quoted: fake });
48
+
49
+ } catch (error) {
50
+ console.error('Resetlink Error:', error);
51
+ await sock.sendMessage(chatId, {
52
+ text: `✦ *${botName}*\nFailed to reset link`
53
+ }, { quoted: fake });
54
+ }
55
+ }
56
+
57
+ module.exports = resetlinkCommand;
@@ -0,0 +1,99 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+
3
+ async function resolveToPhone(sock, jid) {
4
+ if (!jid) return 'unknown';
5
+ const raw = jid.split('@')[0].split(':')[0];
6
+ if (/^\d{7,15}$/.test(raw)) return raw;
7
+ try {
8
+ if (sock?.signalRepository?.lidMapping?.getPNForLID) {
9
+ const formats = [jid, `${raw}:0@lid`, `${raw}@lid`];
10
+ for (const fmt of formats) {
11
+ try {
12
+ const pn = await sock.signalRepository.lidMapping.getPNForLID(fmt);
13
+ if (pn) {
14
+ const num = String(pn).split('@')[0].replace(/[^0-9]/g, '');
15
+ if (num.length >= 7 && num.length <= 15 && num !== raw) return num;
16
+ }
17
+ } catch {}
18
+ }
19
+ }
20
+ const groups = await sock.groupFetchAllParticipating();
21
+ for (const gid of Object.keys(groups)) {
22
+ for (const p of (groups[gid].participants || [])) {
23
+ const pid = (p.id || '').split('@')[0].split(':')[0];
24
+ const pLid = (p.lid || '').split('@')[0].split(':')[0];
25
+ if ((pLid === raw || pid === raw) && pid && /^\d{7,15}$/.test(pid) && pid !== raw) return pid;
26
+ }
27
+ }
28
+ } catch {}
29
+ return raw;
30
+ }
31
+
32
+ async function staffCommand(sock, chatId, msg) {
33
+ try {
34
+ const groupMetadata = await sock.groupMetadata(chatId);
35
+
36
+ let pp;
37
+ try {
38
+ pp = await sock.profilePictureUrl(chatId, 'image');
39
+ } catch {
40
+ pp = 'https://i.imgur.com/2wzGhpF.jpeg';
41
+ }
42
+
43
+ const participants = groupMetadata.participants;
44
+ const groupAdmins = participants.filter(p => p.admin);
45
+
46
+ const adminLines = [];
47
+ for (let i = 0; i < groupAdmins.length; i++) {
48
+ const resolved = await resolveToPhone(sock, groupAdmins[i].id);
49
+ adminLines.push(`${i + 1}. @${resolved}`);
50
+ }
51
+ const listAdmin = adminLines.join('\nšŸ”µ ');
52
+
53
+ const owner = groupMetadata.owner || groupAdmins.find(p => p.admin === 'superadmin')?.id || chatId.split('-')[0] + '@s.whatsapp.net';
54
+
55
+ const ownerParticipant = participants.find(p => p.id === owner);
56
+ const ownerName = ownerParticipant?.name || ownerParticipant?.notify || owner.split('@')[0];
57
+
58
+ const groupCreation = new Date(groupMetadata.creation * 1000).toLocaleDateString();
59
+ const groupDesc = groupMetadata.desc || 'No description available';
60
+ const totalParticipants = participants.length;
61
+ const adminCount = groupAdmins.length;
62
+
63
+ const resolvedOwner = await resolveToPhone(sock, owner);
64
+
65
+ const text = `
66
+ ā„¹ļø *GROUP STAFF INFORMATION*
67
+
68
+ šŸ“› *Group Name:* ${groupMetadata.subject}
69
+ šŸ‘‘ *Group Owner:* @${resolvedOwner}
70
+ šŸ†” *Group JID:* ${chatId}
71
+ šŸ“… *Created:* ${groupCreation}
72
+ šŸ‘„ *Total Members:* ${totalParticipants}
73
+ šŸ›”ļø *Admin Count:* ${adminCount}
74
+
75
+ šŸ“ *Group Description:*
76
+ ${groupDesc}
77
+
78
+ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ ADMIN LIST ────────
79
+ šŸ”µ ${listAdmin}
80
+
81
+
82
+ šŸ’” *Note:* Mentioning all admins for easy contact.
83
+ `.trim();
84
+
85
+ await sock.sendMessage(chatId, {
86
+ image: { url: pp },
87
+ caption: text,
88
+ mentions: [...groupAdmins.map(v => v.id), owner]
89
+ });
90
+
91
+ } catch (error) {
92
+ console.error('Error in staff command:', error);
93
+ await sock.sendMessage(chatId, {
94
+ text: 'Failed to get admin list! Error: ' + error.message
95
+ });
96
+ }
97
+ }
98
+
99
+ module.exports = staffCommand;