Skip to content

Commit

Permalink
feat: Added selectableCount option to WPP.chat.sendCreatePollMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Oct 13, 2022
1 parent ea29fa8 commit f6f3c9f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/chat/functions/sendCreatePollMessage.ts
Expand Up @@ -22,7 +22,9 @@ import {
} from '..';
import { sendRawMessage } from '.';

export type PoolMessageOptions = SendMessageOptions;
export interface PoolMessageOptions extends SendMessageOptions {
selectableCount?: number;
}

/**
* Send a create poll message
Expand All @@ -38,6 +40,18 @@ export type PoolMessageOptions = SendMessageOptions;
* ['Option 1', 'Option 2', 'Option 3']
* );
* ```
* // Selectable Count
* ```javascript
* // Single pool
* WPP.chat.sendCreatePollMessage(
* '[number]@g.us',
* 'A poll name',
* ['Option 1', 'Option 2', 'Option 3'],
* {
* selectableCount: 1,
* }
* );
* ```
*
* @category Message
*/
Expand All @@ -57,7 +71,7 @@ export async function sendCreatePollMessage(
pollName: name,
pollOptions: choices.map((name, localId) => ({ name, localId })),
pollEncKey: self.crypto.getRandomValues(new Uint8Array(32)),
pollSelectableOptionsCount: 0,
pollSelectableOptionsCount: options.selectableCount || 0,
};

return await sendRawMessage(chatId, rawMessage, options);
Expand Down

0 comments on commit f6f3c9f

Please sign in to comment.