feat+fix: send vote messages & vote update event (#3913)

* add send vote function

* Update index.d.ts

* fix and add required modules

* fix poll update in group chat

* adjustments to improvements

* add example usages

* fix eslint

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
This commit is contained in:
RendyCraft047 2025-11-10 02:37:51 +07:00 • committed by GitHub
commit 0c36613cc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 51 additions and 11 deletions

View file

@ -365,7 +365,7 @@ client.on('message', async msg => {
let list = new List('List body', 'btnText', sections, 'Title', 'footer');
client.sendMessage(msg.from, list);
} else if (msg.body === '!reaction') {
msg.react('👍');
await msg.react('👍');
} else if (msg.body === '!sendpoll') {
/** By default the poll is created as a single choice poll: */
await msg.reply(new Poll('Winter or Summer?', ['Winter', 'Summer']));
@ -382,11 +382,20 @@ client.on('message', async msg => {
]
})
);
} else if (msg.body === '!vote') {
if (msg.hasQuotedMsg) {
const quotedMsg = await msg.getQuotedMessage();
if (quotedMsg.type === 'poll_creation') {
await quotedMsg.vote(msg.body.replace('!vote', ''));
} else {
msg.reply('Can only be used on poll messages');
}
}
} else if (msg.body === '!edit') {
if (msg.hasQuotedMsg) {
const quotedMsg = await msg.getQuotedMessage();
if (quotedMsg.fromMe) {
quotedMsg.edit(msg.body.replace('!edit', ''));
await quotedMsg.edit(msg.body.replace('!edit', ''));
} else {
msg.reply('I can only edit my own messages');
}