@itsliaaa/starcore 0.0.0-alpha.0 → 0.0.0-alpha.2
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.
- package/README.md +641 -24
- package/lib/Auth.js +1 -1
- package/lib/Client.js +1 -1
- package/lib/Constants.js +1 -1
- package/lib/Database.js +1 -1
- package/lib/Media.js +1 -1
- package/lib/Message.js +1 -1
- package/lib/Request.js +1 -1
- package/lib/Scraper.js +1 -1
- package/lib/Serialize.js +1 -1
- package/lib/Socket.js +1 -1
- package/lib/Store.js +1 -1
- package/lib/Utilities.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -40,15 +40,98 @@
|
|
|
40
40
|
|
|
41
41
|
Built with a focus on simplicity, and better compatibility with modern WhatsApp features.
|
|
42
42
|
|
|
43
|
-
###
|
|
43
|
+
### 📋 Table of Contents
|
|
44
|
+
|
|
45
|
+
- [📌 Highlights](#-highlights)
|
|
46
|
+
- [📥 Installations](#-installations)
|
|
47
|
+
- [📄 Via `package.json`](#-via-packagejson)
|
|
48
|
+
- [⌨️ Via terminal](#%EF%B8%8F-via-terminal)
|
|
49
|
+
- [🧩 Import (ESM & CJS)](#-import-esm--cjs)
|
|
50
|
+
- [📄 Quick Step](#-quick-step)
|
|
51
|
+
- [⚙️ Advanced Usage](#%EF%B8%8F-advanced-usage)
|
|
52
|
+
- [📡 Events Reference](#-events-reference)
|
|
53
|
+
- [👥 Find User ID](#-find-user-id)
|
|
54
|
+
- [📨 Sending Messages](#-sending-messages)
|
|
55
|
+
- [🔠 Text](#-text)
|
|
56
|
+
- [📰 Link Preview](#-link-preview)
|
|
57
|
+
- [😄 Reaction](#-reaction)
|
|
58
|
+
- [📂 Media](#-media)
|
|
59
|
+
- [⚪ PTV](#-ptv)
|
|
60
|
+
- [📃 Sticker](#-sticker)
|
|
61
|
+
- [📦 Sticker Pack](#-sticker-pack)
|
|
62
|
+
- [👤 Contact](#-contact)
|
|
63
|
+
- [🖼️ Album](#%EF%B8%8F-album)
|
|
64
|
+
- [🗄️ Interactive](#%EF%B8%8F-interactive)
|
|
65
|
+
- [🎠 Carousel](#-carousel)
|
|
66
|
+
- [🔘 Legacy Button](#-legacy-button)
|
|
67
|
+
- [📋 Legacy List](#-legacy-list)
|
|
68
|
+
- [📊 Poll](#-poll)
|
|
69
|
+
- [📈 Poll Result](#-poll-result)
|
|
70
|
+
- [✨ Rich](#-rich)
|
|
71
|
+
- [🗒️ Copy & Forward](#%EF%B8%8F-copy--forward)
|
|
72
|
+
- [🎞️ Status Mention](#%EF%B8%8F-status-mention)
|
|
73
|
+
- [👥 Group Status](#-group-status)
|
|
74
|
+
- [♻️ Modify Messages](#%EF%B8%8F-modify-messages)
|
|
75
|
+
- [🗑️ Delete Messages](#%EF%B8%8F-delete-messages)
|
|
76
|
+
- [✏️ Edit Messages](#%EF%B8%8F-edit-messages)
|
|
77
|
+
- [⚙️ Baileys Features](#%EF%B8%8F-baileys-features)
|
|
78
|
+
- [🔑 Request Custom Pairing Code](#-request-custom-pairing-code)
|
|
79
|
+
- [📣 Newsletter Management](#-newsletter-management)
|
|
80
|
+
- [👥 Group Management](#-group-management)
|
|
81
|
+
- [👥 Community Management](#-community-management)
|
|
82
|
+
- [👤 Profile Management](#-profile-management)
|
|
83
|
+
- [🛒 Business Management](#-business-management)
|
|
84
|
+
- [🔐 Privacy Management](#-privacy-management)
|
|
85
|
+
- [📡 Baileys Events Reference](#-baileys-events-reference)
|
|
86
|
+
- [🗳️ Database](#%EF%B8%8F-database)
|
|
87
|
+
- [🌐 Request](#-request)
|
|
88
|
+
- [🧳 Environments](#-environments)
|
|
89
|
+
- [📚 Exported Modules](#-exported-modules)
|
|
90
|
+
- [🚀 Try the Bot](#-try-the-bot)
|
|
91
|
+
- [📣 Credits](#-credits)
|
|
92
|
+
|
|
93
|
+
### 📥 Installations
|
|
44
94
|
|
|
45
|
-
|
|
95
|
+
> [!IMPORTANT]
|
|
96
|
+
> [`@itsliaaa/starcore`](https://www.npmjs.com/package/@itsliaaa/starcore) does **NOT** install Baileys automatically.
|
|
97
|
+
>
|
|
98
|
+
> You must install a compatible version of Baileys manually before using this package.
|
|
99
|
+
|
|
100
|
+
#### 📄 Via `package.json`
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
# NPM
|
|
104
|
+
"dependencies": {
|
|
105
|
+
"@itsliaaa/starcore": "latest"
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
# GitHub
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"@itsliaaa/starcore": "github:itsliaaa/starcore"
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### ⌨️ Via terminal
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# NPM
|
|
118
|
+
npm i @itsliaaa/starcore@latest
|
|
119
|
+
|
|
120
|
+
# GitHub
|
|
121
|
+
npm i @itsliaaa/starcore@github:itsliaaa/starcore
|
|
122
|
+
```
|
|
46
123
|
|
|
47
|
-
|
|
124
|
+
#### 🧩 Import (ESM & CJS)
|
|
48
125
|
|
|
49
|
-
|
|
126
|
+
```javascript
|
|
127
|
+
// --- ESM
|
|
128
|
+
import { Client } from '@itsliaaa/starcore'
|
|
129
|
+
|
|
130
|
+
// --- CJS (tested and working on Node.js 24 ✅)
|
|
131
|
+
const { Client } = require('@itsliaaa/starcore')
|
|
132
|
+
```
|
|
50
133
|
|
|
51
|
-
### 📄
|
|
134
|
+
### 📄 Quick Step
|
|
52
135
|
|
|
53
136
|
```javascript
|
|
54
137
|
import { Client } from '@itsliaaa/starcore'
|
|
@@ -90,14 +173,13 @@ const client = new Client({
|
|
|
90
173
|
},
|
|
91
174
|
isBotMessageId: (id) =>
|
|
92
175
|
typeof id === 'string' && id.includes('3EB0'),
|
|
93
|
-
messageIdPrefix: '
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
autoFollowNewsletter: '1111122222@newsletter', // String | String[] | false
|
|
176
|
+
messageIdPrefix: 'STARCORE',
|
|
177
|
+
updatePresence: true, // Default: true
|
|
178
|
+
updateProtoOnStartup: true, // Default: true
|
|
179
|
+
autoFollowNewsletter: '1211111111111@newsletter', // String | String[] | false
|
|
98
180
|
newsletterAnnotation: {
|
|
99
|
-
newsletterJid: '',
|
|
100
|
-
newsletterName: ''
|
|
181
|
+
newsletterJid: '1211111111111@newsletter',
|
|
182
|
+
newsletterName: '@itsliaaa/starcore'
|
|
101
183
|
}, // IForwardedNewsletterMessageInfo | false
|
|
102
184
|
saveStoreInterval: 30 * 60 * 1000, // Default: 30 minutes
|
|
103
185
|
temporaryFileInterval: 45 * 60 * 1000, // Default: 45 minutes
|
|
@@ -112,7 +194,7 @@ const client = new Client({
|
|
|
112
194
|
### 📡 Events Reference
|
|
113
195
|
|
|
114
196
|
```javascript
|
|
115
|
-
client.
|
|
197
|
+
client.on('ready', console.log)
|
|
116
198
|
client.on('message', console.log)
|
|
117
199
|
client.on('message.edit', console.log)
|
|
118
200
|
client.on('message.delete', console.log)
|
|
@@ -133,19 +215,19 @@ Quickly resolve a user's `JID` and retrieve both `PN` and `LID` in a synchronous
|
|
|
133
215
|
|
|
134
216
|
```javascript
|
|
135
217
|
// Accepts either @s.whatsapp.net or @lid
|
|
136
|
-
const jidLid = '
|
|
218
|
+
const jidLid = '6281111111111@s.whatsapp.net'
|
|
137
219
|
|
|
138
220
|
const result = sock.findUserId(jidLid)
|
|
139
221
|
|
|
140
222
|
// --- Success
|
|
141
223
|
// {
|
|
142
|
-
// phoneNumber: '
|
|
143
|
-
// lid: '
|
|
224
|
+
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
225
|
+
// lid: '1211111111111@lid'
|
|
144
226
|
// }
|
|
145
227
|
|
|
146
228
|
// --- Not found
|
|
147
229
|
// {
|
|
148
|
-
// phoneNumber: '
|
|
230
|
+
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
149
231
|
// lid: undefined // or null
|
|
150
232
|
// }
|
|
151
233
|
```
|
|
@@ -157,7 +239,7 @@ const result = sock.findUserId(jidLid)
|
|
|
157
239
|
```javascript
|
|
158
240
|
sock.sendText(jid, '👋🏻 Hello', message, {
|
|
159
241
|
mentionAll: false, // Optional
|
|
160
|
-
mentions: ['
|
|
242
|
+
mentions: ['1211111111111@lid', '6281111111111@s.whatsapp.net'], // Optional
|
|
161
243
|
})
|
|
162
244
|
```
|
|
163
245
|
|
|
@@ -175,7 +257,7 @@ sock.sendAdText(jid, '👆🏻 Check it out!', message, {
|
|
|
175
257
|
// --- Send a text message with a large link preview and favicon
|
|
176
258
|
sock.sendAdText(jid, '👆🏻 Check it out!', message, {
|
|
177
259
|
thumbnailUrl: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
178
|
-
title: '
|
|
260
|
+
title: '?? @itsliaaa/starcore',
|
|
179
261
|
description: 'Underrated Baileys Wrapper',
|
|
180
262
|
previewType: 0,
|
|
181
263
|
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
@@ -243,7 +325,7 @@ sock.sendContact(jid, [{
|
|
|
243
325
|
website: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
244
326
|
location: 'Jakarta',
|
|
245
327
|
other: '❤️ Simplified WhatsApp API',
|
|
246
|
-
number: '
|
|
328
|
+
number: '6281111111111'
|
|
247
329
|
}, {
|
|
248
330
|
name: '❤️ My Big Brother',
|
|
249
331
|
org: '👥 Siblings',
|
|
@@ -251,7 +333,7 @@ sock.sendContact(jid, [{
|
|
|
251
333
|
website: 'https://www.npmjs.com/package/@itsliaaa/starcore#readme',
|
|
252
334
|
location: 'Jakarta',
|
|
253
335
|
other: '❤️ Simplified WhatsApp API',
|
|
254
|
-
number: '
|
|
336
|
+
number: '6281111111111'
|
|
255
337
|
}], message)
|
|
256
338
|
```
|
|
257
339
|
|
|
@@ -276,7 +358,7 @@ sock.sendInteractive(jid, [{
|
|
|
276
358
|
icon: 'review' // Optional
|
|
277
359
|
}, {
|
|
278
360
|
text: '📞 Call',
|
|
279
|
-
call: '
|
|
361
|
+
call: '6281111111111'
|
|
280
362
|
}, {
|
|
281
363
|
text: '📋 Copy',
|
|
282
364
|
copy: '@itsliaaa/starcore'
|
|
@@ -449,7 +531,7 @@ sock.sendPoll(jid, [
|
|
|
449
531
|
name: '🔥 Is it good?',
|
|
450
532
|
selectableCount: 1,
|
|
451
533
|
toAnnouncementGroup: false,
|
|
452
|
-
endDate:
|
|
534
|
+
endDate: Date.now() + 28_800_000, // Optional
|
|
453
535
|
hideVoter: false, // Optional
|
|
454
536
|
canAddOption: false // Optional
|
|
455
537
|
})
|
|
@@ -672,6 +754,529 @@ sock.sendGroupStatus(jid, {
|
|
|
672
754
|
})
|
|
673
755
|
```
|
|
674
756
|
|
|
757
|
+
### ♻️ Modify Messages
|
|
758
|
+
|
|
759
|
+
#### 🗑️ Delete Messages
|
|
760
|
+
|
|
761
|
+
```javascript
|
|
762
|
+
sock.sendMessage(jid, {
|
|
763
|
+
delete: message.key
|
|
764
|
+
})
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
#### ✏️ Edit Messages
|
|
768
|
+
|
|
769
|
+
```javascript
|
|
770
|
+
// --- Edit plain text
|
|
771
|
+
sock.sendMessage(jid, {
|
|
772
|
+
text: '✨ I mean, nice!',
|
|
773
|
+
edit: message.key
|
|
774
|
+
})
|
|
775
|
+
|
|
776
|
+
// --- Edit media messages caption
|
|
777
|
+
sock.sendMessage(jid, {
|
|
778
|
+
caption: '✨ I mean, here is the image!',
|
|
779
|
+
edit: message.key
|
|
780
|
+
})
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
### ⚙️ Baileys Features
|
|
784
|
+
|
|
785
|
+
#### 🔑 Request Custom Pairing Code
|
|
786
|
+
|
|
787
|
+
> [!NOTE]
|
|
788
|
+
> The phone number must contain numbers only (no +, (), or -) and must include the country code.
|
|
789
|
+
|
|
790
|
+
```javascript
|
|
791
|
+
const phoneNumber = '6281111111111'
|
|
792
|
+
const customPairingCode = 'STARCORE'
|
|
793
|
+
|
|
794
|
+
await sock.requestPairingCode(phoneNumber, customPairingCode)
|
|
795
|
+
|
|
796
|
+
console.log('🔗 Pairing code', ':', customPairingCode)
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
#### 📣 Newsletter Management
|
|
800
|
+
|
|
801
|
+
```javascript
|
|
802
|
+
// --- Create a new one
|
|
803
|
+
sock.newsletterCreate('@itsliaaa/starcore', '📣 Fresh updates weekly')
|
|
804
|
+
|
|
805
|
+
// --- Get info
|
|
806
|
+
const metadata = sock.newsletterMetadata('1211111111111@newsletter')
|
|
807
|
+
console.dir(metadata, { depth: null })
|
|
808
|
+
|
|
809
|
+
// --- Get subscribers count
|
|
810
|
+
const subscribers = await sock.newsletterSubscribers('1211111111111@newsletter')
|
|
811
|
+
console.dir(subscribers, { depth: null })
|
|
812
|
+
|
|
813
|
+
// --- Follow and Unfollow
|
|
814
|
+
sock.newsletterFollow('1211111111111@newsletter')
|
|
815
|
+
sock.newsletterUnfollow('1211111111111@newsletter')
|
|
816
|
+
|
|
817
|
+
// --- Mute and Unmute
|
|
818
|
+
sock.newsletterMute('1211111111111@newsletter')
|
|
819
|
+
sock.newsletterUnmute('1211111111111@newsletter')
|
|
820
|
+
|
|
821
|
+
// --- Demote admin
|
|
822
|
+
sock.newsletterDemote('1211111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
823
|
+
|
|
824
|
+
// --- Change owner
|
|
825
|
+
sock.newsletterChangeOwner('1211111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
826
|
+
|
|
827
|
+
// --- Update newsletter
|
|
828
|
+
sock.newsletterUpdate('1211111111111@newsletter', { name: '@itsliaaa/starcore' })
|
|
829
|
+
|
|
830
|
+
// --- Change name
|
|
831
|
+
sock.newsletterUpdateName('1211111111111@newsletter', '✨ @itsliaaa/starcore')
|
|
832
|
+
|
|
833
|
+
// --- Change description
|
|
834
|
+
sock.newsletterUpdateDescription('1211111111111@newsletter', '📣 Fresh updates weekly')
|
|
835
|
+
|
|
836
|
+
// --- Change photo
|
|
837
|
+
sock.newsletterUpdatePicture('1211111111111@newsletter', {
|
|
838
|
+
url: 'path/to/image.jpg'
|
|
839
|
+
})
|
|
840
|
+
|
|
841
|
+
// --- Remove photo
|
|
842
|
+
sock.newsletterRemovePicture('1211111111111@newsletter')
|
|
843
|
+
|
|
844
|
+
// --- React to a message
|
|
845
|
+
sock.newsletterReactMessage('1211111111111@newsletter', '100', '💛')
|
|
846
|
+
|
|
847
|
+
// --- Get admin count
|
|
848
|
+
const count = await sock.newsletterAdminCount('1211111111111@newsletter')
|
|
849
|
+
|
|
850
|
+
// --- Get all subscribed newsletters
|
|
851
|
+
const newsletters = await sock.newsletterSubscribed()
|
|
852
|
+
console.dir(newsletters, { depth: null })
|
|
853
|
+
|
|
854
|
+
// --- Fetch newsletter messages
|
|
855
|
+
const messages = sock.newsletterFetchMessages('jid', '1211111111111@newsletter', 50, 0, 0)
|
|
856
|
+
console.dir(messages, { depth: null })
|
|
857
|
+
|
|
858
|
+
// --- Delete newsletter
|
|
859
|
+
sock.newsletterDelete('1211111111111@newsletter')
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
#### 👥 Group Management
|
|
863
|
+
|
|
864
|
+
```javascript
|
|
865
|
+
// --- Create a new one and add participants using their JIDs
|
|
866
|
+
const group = sock.groupCreate('@itsliaaa/starcore', ['6281111111111@s.whatsapp.net'])
|
|
867
|
+
console.dir(group, { depth: null })
|
|
868
|
+
|
|
869
|
+
// --- Get info
|
|
870
|
+
const metadata = await sock.groupMetadata(jid)
|
|
871
|
+
console.dir(metadata, { depth: null })
|
|
872
|
+
|
|
873
|
+
// --- Get group invite code
|
|
874
|
+
const inviteCode = await sock.groupInviteCode(jid)
|
|
875
|
+
console.dir(inviteCode, { depth: null })
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
// --- Revoke invite link
|
|
879
|
+
sock.groupRevokeInvite(jid)
|
|
880
|
+
|
|
881
|
+
// --- Accept group invite
|
|
882
|
+
sock.groupAcceptInvite(inviteCode)
|
|
883
|
+
|
|
884
|
+
// --- Leave group
|
|
885
|
+
sock.groupLeave(jid)
|
|
886
|
+
|
|
887
|
+
// --- Add participants
|
|
888
|
+
sock.groupParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'add')
|
|
889
|
+
|
|
890
|
+
// --- Remove participants
|
|
891
|
+
sock.groupParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'remove')
|
|
892
|
+
|
|
893
|
+
// --- Promote to admin
|
|
894
|
+
sock.groupParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'promote')
|
|
895
|
+
|
|
896
|
+
// --- Demote from admin
|
|
897
|
+
sock.groupParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'demote')
|
|
898
|
+
|
|
899
|
+
// --- Accept join requests
|
|
900
|
+
sock.groupRequestParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'approve')
|
|
901
|
+
|
|
902
|
+
// --- Change name
|
|
903
|
+
sock.groupUpdateSubject(jid, '✨ @itsliaaa/starcore')
|
|
904
|
+
|
|
905
|
+
// --- Change description
|
|
906
|
+
sock.groupUpdateDescription(jid, 'Updated description')
|
|
907
|
+
|
|
908
|
+
// --- Change photo
|
|
909
|
+
sock.updateProfilePicture(jid, {
|
|
910
|
+
url: 'path/to/image.jpg'
|
|
911
|
+
})
|
|
912
|
+
|
|
913
|
+
// --- Remove photo
|
|
914
|
+
sock.removeProfilePicture(jid)
|
|
915
|
+
|
|
916
|
+
// --- Set group as admin only for chatting
|
|
917
|
+
sock.groupSettingUpdate(jid, 'announcement')
|
|
918
|
+
|
|
919
|
+
// --- Set group as open to all for chatting
|
|
920
|
+
sock.groupSettingUpdate(jid, 'not_announcement')
|
|
921
|
+
|
|
922
|
+
// --- Set admin only can edit group info
|
|
923
|
+
sock.groupSettingUpdate(jid, 'locked')
|
|
924
|
+
|
|
925
|
+
// --- Set all participants can edit group info
|
|
926
|
+
sock.groupSettingUpdate(jid, 'unlocked')
|
|
927
|
+
|
|
928
|
+
// --- Set admin only can add participants
|
|
929
|
+
sock.groupMemberAddMode(jid, 'admin_add')
|
|
930
|
+
|
|
931
|
+
// --- Set all participants can add participants
|
|
932
|
+
sock.groupMemberAddMode(jid, 'all_member_add')
|
|
933
|
+
|
|
934
|
+
// --- Enable or disable temporary messages with seconds format
|
|
935
|
+
sock.groupToggleEphemeral(jid, 86400)
|
|
936
|
+
|
|
937
|
+
// --- Disable temporary messages
|
|
938
|
+
sock.groupToggleEphemeral(jid, 0)
|
|
939
|
+
|
|
940
|
+
// --- Enable or disable membership approval mode
|
|
941
|
+
sock.groupJoinApprovalMode(jid, 'on')
|
|
942
|
+
sock.groupJoinApprovalMode(jid, 'off')
|
|
943
|
+
|
|
944
|
+
// --- Get all groups metadata
|
|
945
|
+
const groups = await sock.groupFetchAllParticipating()
|
|
946
|
+
console.dir(groups, { depth: null })
|
|
947
|
+
|
|
948
|
+
// --- Get pending join requests
|
|
949
|
+
const requests = await sock.groupRequestParticipantsList(jid)
|
|
950
|
+
console.dir(requests, { depth: null })
|
|
951
|
+
|
|
952
|
+
// --- Get group info from link
|
|
953
|
+
const group = await sock.groupGetInviteInfo('ABC123456789')
|
|
954
|
+
console.log('👥 Got group info from invite code', ':', group)
|
|
955
|
+
|
|
956
|
+
// --- Update bot member label
|
|
957
|
+
sock.updateMemberLabel(jid, '@itsliaaa/starcore')
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
#### 👥 Community Management
|
|
961
|
+
|
|
962
|
+
```javascript
|
|
963
|
+
// --- Create a new one and add description
|
|
964
|
+
const community = await sock.communityCreate('@itsliaaa/starcore', '📣 Fresh updates weekly')
|
|
965
|
+
console.dir(community, { depth: null })
|
|
966
|
+
|
|
967
|
+
// --- Create a subgroup for community and add participants using their JIDs
|
|
968
|
+
const group = await sock.communityCreateGroup('📢 Announcements', ['6281111111111@s.whatsapp.net'], communityJid)
|
|
969
|
+
|
|
970
|
+
// --- Link an existing group
|
|
971
|
+
sock.communityLinkGroup(groupJid, communityJid)
|
|
972
|
+
|
|
973
|
+
// --- Unlink an existing group
|
|
974
|
+
sock.communityUnlinkGroup(groupJid, communityJid)
|
|
975
|
+
|
|
976
|
+
// --- Get info
|
|
977
|
+
const metadata = await sock.communityMetadata(jid)
|
|
978
|
+
console.dir(metadata, { depth: null })
|
|
979
|
+
|
|
980
|
+
// --- Get community invite code
|
|
981
|
+
const inviteCode = await sock.communityInviteCode(jid)
|
|
982
|
+
console.dir(inviteCode, { depth: null })
|
|
983
|
+
|
|
984
|
+
// --- Revoke invite link
|
|
985
|
+
sock.communityRevokeInvite(jid)
|
|
986
|
+
|
|
987
|
+
// --- Accept community invite
|
|
988
|
+
sock.communityAcceptInvite(inviteCode)
|
|
989
|
+
|
|
990
|
+
// --- Leave community
|
|
991
|
+
sock.communityLeave(jid)
|
|
992
|
+
|
|
993
|
+
// --- Accept join requests
|
|
994
|
+
sock.communityRequestParticipantsUpdate(jid, ['6281111111111@s.whatsapp.net'], 'approve')
|
|
995
|
+
|
|
996
|
+
// --- Change name
|
|
997
|
+
sock.communityUpdateSubject(jid, '✨ @itsliaaa/starcore')
|
|
998
|
+
|
|
999
|
+
// --- Change description
|
|
1000
|
+
sock.communityUpdateDescription(jid, 'Updated description')
|
|
1001
|
+
|
|
1002
|
+
// --- Set community as admin only for chatting
|
|
1003
|
+
sock.communitySettingUpdate(jid, 'announcement')
|
|
1004
|
+
|
|
1005
|
+
// --- Set community as open to all for chatting
|
|
1006
|
+
sock.communitySettingUpdate(jid, 'not_announcement')
|
|
1007
|
+
|
|
1008
|
+
// --- Set admin only can edit community info
|
|
1009
|
+
sock.communitySettingUpdate(jid, 'locked')
|
|
1010
|
+
|
|
1011
|
+
// --- Set all participants can edit community info
|
|
1012
|
+
sock.communitySettingUpdate(jid, 'unlocked')
|
|
1013
|
+
|
|
1014
|
+
// --- Set admin only can add participants
|
|
1015
|
+
sock.communityMemberAddMode(jid, 'admin_add')
|
|
1016
|
+
|
|
1017
|
+
// --- Set all participants can add participants
|
|
1018
|
+
sock.communityMemberAddMode(jid, 'all_member_add')
|
|
1019
|
+
|
|
1020
|
+
// --- Enable or disable temporary messages with seconds format
|
|
1021
|
+
sock.communityToggleEphemeral(jid, 86400)
|
|
1022
|
+
|
|
1023
|
+
// --- Disable temporary messages
|
|
1024
|
+
sock.communityToggleEphemeral(jid, 0)
|
|
1025
|
+
|
|
1026
|
+
// --- Enable or disable membership approval mode
|
|
1027
|
+
sock.communityJoinApprovalMode(jid, 'on')
|
|
1028
|
+
sock.communityJoinApprovalMode(jid, 'off')
|
|
1029
|
+
|
|
1030
|
+
// --- Get all communities metadata
|
|
1031
|
+
const communities = await sock.communityFetchAllParticipating()
|
|
1032
|
+
console.dir(communities, { depth: null })
|
|
1033
|
+
|
|
1034
|
+
// --- Get all community linked groups
|
|
1035
|
+
const linked = await sock.communityFetchLinkedGroups(jid)
|
|
1036
|
+
console.dir(linked, { depth: null })
|
|
1037
|
+
|
|
1038
|
+
// --- Get pending join requests
|
|
1039
|
+
const requests = await sock.communityRequestParticipantsList(jid)
|
|
1040
|
+
console.dir(requests, { depth: null })
|
|
1041
|
+
|
|
1042
|
+
// --- Get community info from link
|
|
1043
|
+
const community = await sock.communityGetInviteInfo('ABC123456789')
|
|
1044
|
+
console.log('👥 Got community info from invite code', ':', community)
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
#### 👤 Profile Management
|
|
1048
|
+
|
|
1049
|
+
```javascript
|
|
1050
|
+
// --- Get user profile picture
|
|
1051
|
+
const url = await sock.profilePictureUrl(jid, 'image')
|
|
1052
|
+
console.log('🖼️ Got user profile url', url)
|
|
1053
|
+
|
|
1054
|
+
// --- Update profile picture
|
|
1055
|
+
sock.updateProfilePicture(jid, buffer)
|
|
1056
|
+
sock.updateProfilePicture(jid, { url })
|
|
1057
|
+
|
|
1058
|
+
// --- Remove profile picture
|
|
1059
|
+
sock.removeProfilePicture(jid)
|
|
1060
|
+
|
|
1061
|
+
// --- Update profile name
|
|
1062
|
+
sock.updateProfileName('My Name')
|
|
1063
|
+
|
|
1064
|
+
// --- Update profile status
|
|
1065
|
+
sock.updateProfileStatus('Available')
|
|
1066
|
+
|
|
1067
|
+
// --- Presence
|
|
1068
|
+
sock.sendPresenceUpdate('available', jid)
|
|
1069
|
+
sock.presenceSubscribe(jid)
|
|
1070
|
+
|
|
1071
|
+
// --- Read receipts
|
|
1072
|
+
sock.readMessages([message.key])
|
|
1073
|
+
sock.sendReceipt(jid, participant, [messageId], 'read')
|
|
1074
|
+
|
|
1075
|
+
// --- Block user
|
|
1076
|
+
sock.updateBlockStatus(jid, 'block')
|
|
1077
|
+
|
|
1078
|
+
// --- Unblock user
|
|
1079
|
+
sock.updateBlockStatus(jid, 'unblock')
|
|
1080
|
+
|
|
1081
|
+
// --- Fetch blocklist
|
|
1082
|
+
const blocked = await sock.fetchBlocklist()
|
|
1083
|
+
console.dir(blocked, { depth: null })
|
|
1084
|
+
|
|
1085
|
+
// --- Modify chats
|
|
1086
|
+
sock.chatModify({
|
|
1087
|
+
archive: true,
|
|
1088
|
+
lastMessageOrig: message,
|
|
1089
|
+
lastMessage: message
|
|
1090
|
+
}, jid)
|
|
1091
|
+
|
|
1092
|
+
// --- Star messages
|
|
1093
|
+
sock.star(jid, [{ id: messageId, fromMe: true }], true)
|
|
1094
|
+
|
|
1095
|
+
// --- Contact
|
|
1096
|
+
sock.addOrEditContact(jid, { displayName: 'Starseed' })
|
|
1097
|
+
sock.removeContact(jid)
|
|
1098
|
+
|
|
1099
|
+
// --- Label
|
|
1100
|
+
sock.addChatLabel(jid, labelId)
|
|
1101
|
+
sock.removeChatLabel(jid, labelId)
|
|
1102
|
+
sock.addMessageLabel(jid, messageId, labelId)
|
|
1103
|
+
|
|
1104
|
+
// --- Favorites
|
|
1105
|
+
sock.keepFavorites([
|
|
1106
|
+
'6281111111111@s.whatsapp.net',
|
|
1107
|
+
'1211111111111@g.us'
|
|
1108
|
+
])
|
|
1109
|
+
sock.keepFavorites([
|
|
1110
|
+
'6281111111111@s.whatsapp.net' // only this one remains
|
|
1111
|
+
])
|
|
1112
|
+
|
|
1113
|
+
// --- App state sync
|
|
1114
|
+
sock.resyncAppState(['regular', 'critical_block'], true)
|
|
1115
|
+
|
|
1116
|
+
// --- Get business profile
|
|
1117
|
+
const profile = await sock.getBusinessProfile(jid)
|
|
1118
|
+
console.dir(profile, { depth: null })
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
#### 🛒 Business Management
|
|
1122
|
+
|
|
1123
|
+
```javascript
|
|
1124
|
+
// --- Create a new product
|
|
1125
|
+
const product = await sock.productCreate({
|
|
1126
|
+
name: '🧩 Starseed (Premium)',
|
|
1127
|
+
description: 'Get a full version of Starseed!',
|
|
1128
|
+
price: 100000,
|
|
1129
|
+
currency: 'IDR',
|
|
1130
|
+
originCountryCode: 'ID',
|
|
1131
|
+
images: [
|
|
1132
|
+
bufferImage,
|
|
1133
|
+
{
|
|
1134
|
+
url: './path/to/image.jpg'
|
|
1135
|
+
}
|
|
1136
|
+
]
|
|
1137
|
+
})
|
|
1138
|
+
console.dir(product, { depth: null })
|
|
1139
|
+
|
|
1140
|
+
// --- Update product
|
|
1141
|
+
await sock.productUpdate(productId, {
|
|
1142
|
+
name: '🧩 Starseed (Premium)',
|
|
1143
|
+
description: 'Get a full version of Starseed with more features!',
|
|
1144
|
+
price: 75000,
|
|
1145
|
+
currency: 'IDR',
|
|
1146
|
+
images: [
|
|
1147
|
+
{
|
|
1148
|
+
url: './path/to/image.jpg'
|
|
1149
|
+
}
|
|
1150
|
+
]
|
|
1151
|
+
})
|
|
1152
|
+
|
|
1153
|
+
// --- Delete product
|
|
1154
|
+
sock.productDelete([productId])
|
|
1155
|
+
|
|
1156
|
+
// --- Get catalog info
|
|
1157
|
+
const { products, nextPageCursor } = await sock.getCatalog({
|
|
1158
|
+
jid: '6281111111111@s.whatsapp.net',
|
|
1159
|
+
limit: 10
|
|
1160
|
+
})
|
|
1161
|
+
|
|
1162
|
+
// --- Get collections
|
|
1163
|
+
const collections = await sock.getCollections('6281111111111@s.whatsapp.net', 10)
|
|
1164
|
+
console.dir(collections, { depth: null })
|
|
1165
|
+
|
|
1166
|
+
// --- Get order info
|
|
1167
|
+
const order = await sock.getOrderDetails(orderId, tokenBase64)
|
|
1168
|
+
console.dir(order, { depth: null })
|
|
1169
|
+
|
|
1170
|
+
// --- Update business profile
|
|
1171
|
+
await sock.updateBusinessProfile({
|
|
1172
|
+
address: 'Jakarta, Indonesia',
|
|
1173
|
+
description: '🛒 Official Starseed Store',
|
|
1174
|
+
websites: ['https://www.npmjs.com/package/@itsliaaa/starcore'],
|
|
1175
|
+
email: 'more-more@gmail.com',
|
|
1176
|
+
hours: {
|
|
1177
|
+
timezone: 'Asia/Jakarta',
|
|
1178
|
+
days: [{ day: 'mon', mode: 'open_24h' }]
|
|
1179
|
+
}
|
|
1180
|
+
})
|
|
1181
|
+
|
|
1182
|
+
// --- Update cover
|
|
1183
|
+
sock.updateCoverPhoto({
|
|
1184
|
+
url: './path/to/image.jpg'
|
|
1185
|
+
})
|
|
1186
|
+
|
|
1187
|
+
// --- Remove cover
|
|
1188
|
+
sock.removeCoverPhoto(coverId)
|
|
1189
|
+
|
|
1190
|
+
// --- Update quick replies
|
|
1191
|
+
sock.addOrEditQuickReply({
|
|
1192
|
+
shortcut: 'hello',
|
|
1193
|
+
message: 'Hello from business account',
|
|
1194
|
+
})
|
|
1195
|
+
|
|
1196
|
+
// --- Remove quick reply
|
|
1197
|
+
sock.removeQuickReply(timestamp)
|
|
1198
|
+
```
|
|
1199
|
+
|
|
1200
|
+
#### 🔐 Privacy Management
|
|
1201
|
+
|
|
1202
|
+
```javascript
|
|
1203
|
+
// --- Update last seen privacy
|
|
1204
|
+
sock.updateLastSeenPrivacy('all')
|
|
1205
|
+
sock.updateLastSeenPrivacy('contacts')
|
|
1206
|
+
sock.updateLastSeenPrivacy('contact_blacklist')
|
|
1207
|
+
sock.updateLastSeenPrivacy('nobody')
|
|
1208
|
+
|
|
1209
|
+
// --- Update online privacy
|
|
1210
|
+
sock.updateOnlinePrivacy('all')
|
|
1211
|
+
sock.updateOnlinePrivacy('match_last_seen')
|
|
1212
|
+
|
|
1213
|
+
// --- Update profile picture privacy
|
|
1214
|
+
sock.updateProfilePicturePrivacy('contacts')
|
|
1215
|
+
|
|
1216
|
+
// --- Update status privacy
|
|
1217
|
+
sock.updateStatusPrivacy('contacts')
|
|
1218
|
+
|
|
1219
|
+
// --- Update read receipts privacy
|
|
1220
|
+
sock.updateReadReceiptsPrivacy('all')
|
|
1221
|
+
sock.updateReadReceiptsPrivacy('none')
|
|
1222
|
+
|
|
1223
|
+
// --- Update groups add privacy
|
|
1224
|
+
sock.updateGroupsAddPrivacy('all')
|
|
1225
|
+
sock.updateGroupsAddPrivacy('contacts')
|
|
1226
|
+
|
|
1227
|
+
// --- Update messages privacy
|
|
1228
|
+
sock.updateMessagesPrivacy('all')
|
|
1229
|
+
sock.updateMessagesPrivacy('contacts')
|
|
1230
|
+
sock.updateMessagesPrivacy('nobody')
|
|
1231
|
+
|
|
1232
|
+
// --- Update call privacy
|
|
1233
|
+
sock.updateCallPrivacy('everyone')
|
|
1234
|
+
|
|
1235
|
+
// --- Update default disappearing mode
|
|
1236
|
+
sock.updateDefaultDisappearingMode(86400)
|
|
1237
|
+
|
|
1238
|
+
// --- Update link previews privacy
|
|
1239
|
+
sock.updateDisableLinkPreviewsPrivacy(true)
|
|
1240
|
+
```
|
|
1241
|
+
|
|
1242
|
+
#### 📡 Baileys Events Reference
|
|
1243
|
+
|
|
1244
|
+
```javascript
|
|
1245
|
+
sock.ev.on('connection.update', console.log)
|
|
1246
|
+
sock.ev.on('creds.update', console.log)
|
|
1247
|
+
sock.ev.on('messaging-history.set', console.log)
|
|
1248
|
+
sock.ev.on('messaging-history.status', console.log)
|
|
1249
|
+
sock.ev.on('chats.upsert', console.log)
|
|
1250
|
+
sock.ev.on('chats.update', console.log)
|
|
1251
|
+
sock.ev.on('chats.delete', console.log)
|
|
1252
|
+
sock.ev.on('chats.lock', console.log)
|
|
1253
|
+
sock.ev.on('lid-mapping.update', console.log)
|
|
1254
|
+
sock.ev.on('presence.update', console.log)
|
|
1255
|
+
sock.ev.on('contacts.upsert', console.log)
|
|
1256
|
+
sock.ev.on('contacts.update', console.log)
|
|
1257
|
+
sock.ev.on('messages.delete', console.log)
|
|
1258
|
+
sock.ev.on('messages.update', console.log)
|
|
1259
|
+
sock.ev.on('messages.media-update', console.log)
|
|
1260
|
+
sock.ev.on('messages.upsert', console.log)
|
|
1261
|
+
sock.ev.on('messages.reaction', console.log)
|
|
1262
|
+
sock.ev.on('message-receipt.update', console.log)
|
|
1263
|
+
sock.ev.on('groups.upsert', console.log)
|
|
1264
|
+
sock.ev.on('groups.update', console.log)
|
|
1265
|
+
sock.ev.on('group-participants.update', console.log)
|
|
1266
|
+
sock.ev.on('group.join-request', console.log)
|
|
1267
|
+
sock.ev.on('group.member-tag.update', console.log)
|
|
1268
|
+
sock.ev.on('blocklist.set', console.log)
|
|
1269
|
+
sock.ev.on('blocklist.update', console.log)
|
|
1270
|
+
sock.ev.on('call', console.log)
|
|
1271
|
+
sock.ev.on('labels.edit', console.log)
|
|
1272
|
+
sock.ev.on('labels.association', console.log)
|
|
1273
|
+
sock.ev.on('newsletter.reaction', console.log)
|
|
1274
|
+
sock.ev.on('newsletter.view', console.log)
|
|
1275
|
+
sock.ev.on('newsletter-participants.update', console.log)
|
|
1276
|
+
sock.ev.on('newsletter-settings.update', console.log)
|
|
1277
|
+
sock.ev.on('settings.update', console.log)
|
|
1278
|
+
```
|
|
1279
|
+
|
|
675
1280
|
### 🗳️ Database
|
|
676
1281
|
|
|
677
1282
|
> [!IMPORTANT]
|
|
@@ -730,6 +1335,18 @@ const postResult = await someApi('path/to/post', null, {
|
|
|
730
1335
|
})
|
|
731
1336
|
```
|
|
732
1337
|
|
|
1338
|
+
### 🧳 Environments
|
|
1339
|
+
|
|
1340
|
+
> [!TIP]
|
|
1341
|
+
> The following environment variables use these values by default. Customize them through [`dotenv`](https://www.npmjs.com/package/dotenv) if needed.
|
|
1342
|
+
|
|
1343
|
+
```ini
|
|
1344
|
+
# .env
|
|
1345
|
+
FFMPEG_PATH="ffmpeg"
|
|
1346
|
+
TEMPORARY_PATH="temp"
|
|
1347
|
+
TZ="Asia/Jakarta"
|
|
1348
|
+
```
|
|
1349
|
+
|
|
733
1350
|
### 📚 Exported Modules
|
|
734
1351
|
|
|
735
1352
|
```javascript
|
|
@@ -744,7 +1361,7 @@ import {
|
|
|
744
1361
|
|
|
745
1362
|
### 🚀 Try the Bot
|
|
746
1363
|
|
|
747
|
-
A fast, lightweight, and modular WhatsApp bot built with [@itsliaaa/
|
|
1364
|
+
A fast, lightweight, and modular WhatsApp bot built with [@itsliaaa/baileys](https://www.npmjs.com/package/@itsliaaa/baileys).
|
|
748
1365
|
Perfect for managing groups, moderating chats, and adding fun with quiz games and handy tools.
|
|
749
1366
|
|
|
750
1367
|
👉🏻 [@itsliaaa/starseed](https://github.com/itsliaaa/starseed#readme)
|