From 823701a9c7eb9e734868524e8a2afa79448a34bb Mon Sep 17 00:00:00 2001 From: BochilGaming <79433517+BochilGaming@users.noreply.github.com> Date: Mon, 15 Nov 2021 14:14:43 +0700 Subject: [PATCH] Add groupRevokeInvite, groupAcceptInvite and fix groupLeave (#860) * Update groups.ts * Fix: error TS2448: Block-scoped variable 'result' used before its declaration. --- src/Socket/groups.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Socket/groups.ts b/src/Socket/groups.ts index 508760e..b002534 100644 --- a/src/Socket/groups.ts +++ b/src/Socket/groups.ts @@ -52,7 +52,7 @@ export const makeGroupsSocket = (config: SocketConfig) => { ) return extractGroupMetadata(result) }, - groupLeave: async(jid: string) => { + groupLeave: async(id: string) => { await groupQuery( '@g.us', 'set', @@ -61,7 +61,7 @@ export const makeGroupsSocket = (config: SocketConfig) => { tag: 'leave', attrs: { }, content: [ - { tag: 'group', attrs: { jid } } + { tag: 'group', attrs: { id } } ] } ] @@ -124,6 +124,16 @@ export const makeGroupsSocket = (config: SocketConfig) => { const inviteNode = getBinaryNodeChild(result, 'invite') return inviteNode.attrs.code }, + groupRevokeInvite: async (jid: string) => { + const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]) + const inviteNode = getBinaryNodeChild(result, 'invite') + return inviteNode.attrs.code + }, + groupAcceptInvite: async (code: string) => { + const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]) + const result = getBinaryNodeChild(results, 'group') + return result.attrs.jid + }, groupToggleEphemeral: async(jid: string, ephemeralExpiration: number) => { const content: BinaryNode = ephemeralExpiration ? { tag: 'ephemeral', attrs: { ephemeral: ephemeralExpiration.toString() } } : @@ -202,4 +212,4 @@ export const extractGroupMetadata = (result: BinaryNode) => { ephemeralDuration: eph ? +eph : undefined } return metadata -} \ No newline at end of file +}