Groups trait provides methods for managing WhatsApp groups, including creating groups, managing participants, and modifying group settings.
Access
Access group operations through the client:Methods
query_info
Query group information with caching support.jid- Group JID (must end with@g.us)
GroupInfo- Contains participants list and addressing mode
get_participating
Get all groups the client is participating in.HashMap<String, GroupMetadata>- Map of group JID strings to metadata
id: Jid- Group JIDsubject: String- Group nameparticipants: Vec<GroupParticipant>- List of participantsaddressing_mode: AddressingMode- Phone number or LID mode
jid: Jid- Participant JIDphone_number: Option<Jid>- Phone number JID (for LID groups)is_admin: bool- Whether participant is an admin
get_metadata
Get metadata for a specific group.jid- Group JID
GroupMetadata- Group metadata (seeget_participatingfor fields)
create_group
Create a new group.options: GroupCreateOptions- Group creation optionssubject: GroupSubject- Group name (max 100 characters)participants: Vec<GroupParticipantOptions>- Initial participantsdescription: Option<GroupDescription>- Optional description (max 2048 characters)member_add_mode: MemberAddMode- Who can add membersmembership_approval_mode: MembershipApprovalMode- Require admin approval
CreateGroupResultwithgid: Jidfield
set_subject
Change the group name.jid- Group JIDsubject- New group name (max 100 characters)
set_description
Set or delete the group description.jid- Group JIDdescription- New description (max 2048 characters) orNoneto deleteprev- Current description ID for conflict detection (passNoneif unknown)
leave
Leave a group.jid- Group JID to leave
add_participants
Add participants to a group.jid- Group JIDparticipants- Array of participant JIDs to add
Vec<ParticipantChangeResponse>- Result for each participant
remove_participants
Remove participants from a group.jid- Group JIDparticipants- Array of participant JIDs to remove
Vec<ParticipantChangeResponse>- Result for each participant
promote_participants
Promote participants to admin.jid- Group JIDparticipants- Array of participant JIDs to promote
demote_participants
Demote admin participants to regular members.jid- Group JIDparticipants- Array of admin JIDs to demote
get_invite_link
Get or reset the group invite link.jid- Group JIDreset- Whether to reset and generate a new invite link
String- Invite link code
Types
GroupSubject
Validated group name with 100 character limit.GroupDescription
Validated group description with 2048 character limit.MemberAddMode
MembershipApprovalMode
AddressingMode
Error Handling
All methods returnResult<T, anyhow::Error>. Common errors:
- Invalid JID format
- Network errors
- Permission denied (not admin)
- Group not found
- Subject/description too long
- Participant not found