Skip to content

Commit

Permalink
feat: Added client.sendPollMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Oct 22, 2022
1 parent e23b49b commit 3acdfe3
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/api/layers/sender.layer.ts
Expand Up @@ -21,6 +21,7 @@ import type {
LocationMessageOptions,
SendMessageReturn,
TextMessageOptions,
PoolMessageOptions,
} from '@wppconnect/wa-js/dist/chat';
import * as path from 'path';
import { JSONObject, Page } from 'puppeteer';
Expand Down Expand Up @@ -1208,6 +1209,54 @@ export class SenderLayer extends ListenerLayer {
);
}

/**
* Send a create poll message
*
* Note: This only works for groups
*
* @example
* ```javascript
* // Single pool
* client.sendPollMessage(
* '[number]@g.us',
* 'A poll name',
* ['Option 1', 'Option 2', 'Option 3']
* );
* ```
* // Selectable Count
* ```javascript
* // Single pool
* client.sendPollMessage(
* '[number]@g.us',
* 'A poll name',
* ['Option 1', 'Option 2', 'Option 3'],
* {
* selectableCount: 1,
* }
* );
* ```
*
* @category Chat
*/
public async sendPollMessage(
chatId: string,
name: string,
choices: string[],
options?: PoolMessageOptions
) {
return await evaluateAndReturn(
this.page,
({ chatId, name, choices, options }) => {
WPP.chat.sendCreatePollMessage(chatId, name, choices, options);
},
{
chatId,
name,
choices,
options: options as unknown as JSONObject,
}
);
}
/**
* Sets the chat state
* Deprecated in favor of Use startTyping or startRecording functions
Expand Down

0 comments on commit 3acdfe3

Please sign in to comment.