diff --git a/src/group/functions/create.ts b/src/group/functions/create.ts index fe4d094ed5..2466498442 100644 --- a/src/group/functions/create.ts +++ b/src/group/functions/create.ts @@ -46,13 +46,17 @@ import * as wa_functions from '../../whatsapp/functions'; * // How to send a custom invite link * const link = 'https://chat.whatsapp.com/' + result['number@c.us'].invite_code; * console.log(link); + * + * // Create a Subgroup for a community + * const result = await WPP.group.create('Test Group', ['number@c.us'], 'communit@g.us'); * ``` * * @category Group */ export async function create( groupName: string, - participantsIds: (string | Wid) | (string | Wid)[] + participantsIds: (string | Wid) | (string | Wid)[], + parentGroup: string | Wid ): Promise<{ gid: Wid; participants: { @@ -99,7 +103,14 @@ export async function create( wids.push(info.wid); } - const result = await wa_functions.sendCreateGroup(groupName, wids); + const parentWid = parentGroup ? assertWid(parentGroup) : undefined; + + const result = await wa_functions.sendCreateGroup( + groupName, + wids, + undefined, + parentWid + ); if (result.gid) { const chatGroup = await Chat.find(result.gid); diff --git a/src/whatsapp/functions/createGroup.ts b/src/whatsapp/functions/createGroup.ts index c6cdeb1301..e92da552a2 100644 --- a/src/whatsapp/functions/createGroup.ts +++ b/src/whatsapp/functions/createGroup.ts @@ -24,7 +24,7 @@ export declare function createGroup( groupName: string, participants: Wid[], ephemeral?: number, - dogfooding?: boolean + parentGroup?: Wid ): Promise<{ wid: Wid; participants: { diff --git a/src/whatsapp/functions/sendCreateGroup.ts b/src/whatsapp/functions/sendCreateGroup.ts index 257596d7c7..aeed8e753d 100644 --- a/src/whatsapp/functions/sendCreateGroup.ts +++ b/src/whatsapp/functions/sendCreateGroup.ts @@ -24,7 +24,7 @@ export declare function sendCreateGroup( groupName: string, participants: Wid[], ephemeral?: number, - dogfooding?: boolean + parentGroup?: Wid ): Promise<{ gid: Wid; participants: ( @@ -60,13 +60,13 @@ webpack.injectFallbackModule('sendCreateGroup', { groupName: string, participants: Wid[], ephemeral?: number, - dogfooding?: boolean + parentGroup?: Wid ) => { return await createGroup( groupName, participants, ephemeral, - dogfooding + parentGroup ).then((e) => ({ gid: e.wid, participants: e.participants.map((e) => ({