mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 04:29:15 +00:00
feat: add GroupChat types (#485)
Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
committed by
Pedro S. Lopez
parent
32575490da
commit
5c6195738f
63
index.d.ts
vendored
63
index.d.ts
vendored
@@ -822,6 +822,69 @@ declare namespace WAWebJS {
|
||||
export interface PrivateChat extends Chat {
|
||||
|
||||
}
|
||||
|
||||
export type GroupParticipant = {
|
||||
id: ContactId,
|
||||
isAdmin: boolean
|
||||
isSuperAdmin: boolean
|
||||
}
|
||||
|
||||
/** Promotes or demotes participants by IDs to regular users or admins */
|
||||
export type ChangeParticipantsPermisions =
|
||||
(participantIds: Array<string>) => Promise<{ status: number }>
|
||||
|
||||
/** Adds or removes a list of participants by ID to the group */
|
||||
export type ChangeGroupParticipants =
|
||||
(participantIds: Array<string>) => Promise<{
|
||||
status: number;
|
||||
participants: Array<{
|
||||
[key: string]: {
|
||||
code: number
|
||||
}
|
||||
}>
|
||||
} & {
|
||||
[key: string]: number;
|
||||
}>
|
||||
|
||||
export interface GroupChat extends Chat {
|
||||
/** Group owner */
|
||||
owner: ContactId;
|
||||
/** Date at which the group was created */
|
||||
createdAt: Date;
|
||||
/** Group description */
|
||||
description: string;
|
||||
/** Group participants */
|
||||
participants: Array<GroupParticipant>;
|
||||
/** Adds a list of participants by ID to the group */
|
||||
addParticipants: ChangeGroupParticipants;
|
||||
/** Removes a list of participants by ID to the group */
|
||||
removeParticipants: ChangeGroupParticipants;
|
||||
/** Promotes participants by IDs to admins */
|
||||
promoteParticipants: ChangeParticipantsPermisions;
|
||||
/** Demotes participants by IDs to regular users */
|
||||
demoteParticipants: ChangeParticipantsPermisions;
|
||||
/** Updates the group subject */
|
||||
setSubject: (subject: string) => Promise<void>;
|
||||
/** Updates the group description */
|
||||
setDescription: (description: string) => Promise<void>;
|
||||
/** Updates the group settings to only allow admins to send messages
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
setMessagesAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
|
||||
/**
|
||||
* Updates the group settings to only allow admins to edit group info (title, description, photo).
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
setInfoAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
|
||||
/** Gets the invite code for a specific group */
|
||||
getInviteCode: () => Promise<string>;
|
||||
/** Invalidates the current group invite code and generates a new one */
|
||||
revokeInvite: () => Promise<void>;
|
||||
/** Makes the bot leave the group */
|
||||
leave: () => Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
export = WAWebJS
|
||||
|
||||
Reference in New Issue
Block a user