You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fulfill a feature in /poll command:voteLimit option
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.
測試步驟
/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
make a user vote on 1, 2, 3 polling options
make the user vote on the fourth option, 4
Bot should reply that "The maximum number of options you can vote is 3. "
教學
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.
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.
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.
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.
The text was updated successfully, but these errors were encountered:
continue from: #98
Slash Command Quest
任務描述
Fulfill a feature in
/poll
command:voteLimit
option測試步驟
/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
make a user vote on
1, 2, 3
polling optionsmake the user vote on the fourth option,
4
Bot should reply that "The maximum number of options you can vote is 3. "
教學
Modification of
PollCommandListener
class: You'll need to include a new variablevoteLimit
in the class. This will be used to store the maximum number of votes a user can have.Parsing
voteLimit
from options: Update theparsePollingSettingFromOptions
method to check for the presence ofvoteLimit
. If the option is found, parse its value and store it in thePollingSetting
object.Checking vote count in
onMessageReactionAdd
hook: Here, verify ifvoteLimit
is defined inPollingSetting
. If it is, cross-check it against the user's current vote count.Handling exceeded vote limit: If the user's vote count surpasses
voteLimit
, utilize thereply(...).complete()
function to notify the user about their prohibited action. After this, you should immediately exit the method to prevent any further processing.The text was updated successfully, but these errors were encountered: