mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Group update description (#859)
* Added groupUpdateDescription * Updated README Co-authored-by: Ilya Borodin <ilya.borodin@botconversa.com.br>
This commit is contained in:
@@ -542,6 +542,10 @@ Of course, replace ``` xyz ``` with an actual ID.
|
||||
``` ts
|
||||
await conn.groupUpdateSubject("abcd-xyz@g.us", "New Subject!")
|
||||
```
|
||||
- To change the group's description
|
||||
``` ts
|
||||
await conn.groupUpdateDescription("abcd-xyz@g.us", "New Description!")
|
||||
```
|
||||
- To change group settings
|
||||
``` ts
|
||||
// only allow admins to send messages
|
||||
|
||||
@@ -100,6 +100,25 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
||||
const participantsAffected = getBinaryNodeChildren(node!, 'participant')
|
||||
return participantsAffected.map(p => p.attrs.jid)
|
||||
},
|
||||
groupUpdateDescription: async(jid: string, description?: string) => {
|
||||
const metadata = await groupMetadata(jid);
|
||||
const prev = metadata.descId ?? null;
|
||||
|
||||
await groupQuery(
|
||||
jid,
|
||||
'set',
|
||||
[
|
||||
{
|
||||
tag: 'description',
|
||||
attrs: {
|
||||
...( description ? { id: generateMessageID() } : { delete: 'true' } ),
|
||||
...(prev ? { prev } : {})
|
||||
},
|
||||
content: description ? [{tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8')}] : null
|
||||
}
|
||||
]
|
||||
)
|
||||
},
|
||||
groupInviteCode: async(jid: string) => {
|
||||
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }])
|
||||
const inviteNode = getBinaryNodeChild(result, 'invite')
|
||||
|
||||
Reference in New Issue
Block a user