Skip to content

Feat/iss 30/poll votation message update#208

Merged
Israel-Laguan merged 7 commits intodevfrom
feat/iss-30/poll-votation-MessageUpdate
Jul 10, 2025
Merged

Feat/iss 30/poll votation message update#208
Israel-Laguan merged 7 commits intodevfrom
feat/iss-30/poll-votation-MessageUpdate

Conversation

@joset98
Copy link
Collaborator

@joset98 joset98 commented Apr 23, 2025

Description

This PR introduces the following:

  • A new event listener for MessageUpdate.
  • Logic to identify if an updated message corresponds to a finalized poll. This might involve checking for specific changes in the embed or message properties.
  • A mechanism to extract the vote counts for each option from the updated message embed (if this information is available).
  • Logic to determine if a draw has occurred based on the extracted vote counts.
  • Updated result reporting to correctly handle and display draw outcomes.

Benefits:

  • Accurate reporting of poll results, including scenarios where there is no clear winner (draws).
  • Improved user experience by providing complete and accurate poll results.

Type of change

  • new feature (non-breaking change which add functionality)

Checklist

This issue can be closed when the following tasks are complete:

  • Run project without errors.
  • Run commands without errors.
  • New event feature is working fine

How to test

  1. Run the project
  2. Create a poll votation with /vote-points command
  3. Vote for any option and wait for poll is closed
  4. Check when a draw occurred

Screenshots

image

@joset98 joset98 self-assigned this Apr 23, 2025
@joset98 joset98 linked an issue Apr 23, 2025 that may be closed by this pull request
src/config.js Outdated
boostedPointTagId:
process.env.ADD_BOOSTED_POINT_TAG_ID || '1263873487953592381',
},
operationMode: process.env.OP_MODE || 'max',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the ENV this name is weird, what about is something like 'VOTE_DRAW_MODE'

for (const pollAnswer of pollAnswers.values()) {
if (pollAnswer.voteCount > maxVoteCount) {
maxVoteCount = pollAnswer.voteCount;
topVoted.length = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this one needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry which one do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set the length to 0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to reset the array when a new higher values is found

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm try to reset like topVoted = []


module.exports = {
name: Events.MessageUpdate,
async execute(_client, message) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the underscore in client? Maybe use just 'client' as name for the param?

}
}

return topVoted.length > 0 ? topVoted : [maxVoteCount];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to modify the function so always returns the top pollAnswer

now it return one answer OR an array, is confusing

Copy link

@DanishIbrahimKhan DanishIbrahimKhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,

@Israel-Laguan Israel-Laguan merged commit 30d244c into dev Jul 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Poll Votations: Explore using MessageUpdate instead of MessageCreate

3 participants