Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[任務] /poll:add new option "voteLimit" indicates that how many votes can a user have. #117

Open
Johnny850807 opened this issue May 28, 2023 · 0 comments

Comments

@Johnny850807
Copy link
Contributor

Johnny850807 commented May 28, 2023

continue from: #98

Slash Command Quest

任務描述

Fulfill a feature in /poll command:voteLimit option

  1. the option is not required, if the argument is not present, then there's no limit on the user's votes; if the option is present, that says, voteLimit=3, then every user can only vote on 0~3 polling options.

測試步驟

  1. /poll time=20 timeUnit=SECONDS voteLimit=3 question=A options=1,2,3,4,5,6,7
    should see the polling session created with a message shown

  2. make a user vote on 1, 2, 3 polling options

  3. make the user vote on the fourth option, 4
    Bot should reply that "The maximum number of options you can vote is 3. "

教學

  1. Modification of PollCommandListener class: You'll need to include a new variable voteLimit in the class. This will be used to store the maximum number of votes a user can have.

  2. Parsing voteLimit from options: Update the parsePollingSettingFromOptions method to check for the presence of voteLimit. If the option is found, parse its value and store it in the PollingSetting object.

  3. Checking vote count in onMessageReactionAdd hook: Here, verify if voteLimit is defined in PollingSetting. If it is, cross-check it against the user's current vote count.

  4. Handling exceeded vote limit: If the user's vote count surpasses voteLimit, utilize the reply(...).complete() function to notify the user about their prohibited action. After this, you should immediately exit the method to prevent any further processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant