Firebot icon indicating copy to clipboard operation
Firebot copied to clipboard

feat (vars): Add $pollTitle and $pollChoices Variables

Open phroggster opened this issue 1 year ago • 8 comments

Description of the Change

  • Add a $pollTitle variable that provides the name of a poll being started, updated, and/or ended.
  • Add a $pollChoices variable that can return any piece of information about poll choices for the same event types without requiring $objectWalkPath or $arrayElement-style walking:.
  • Raw $pollChoices will yield an array of the choices available (with id, index, points, title, votes properties), but accepts three optional parameters:
Param Name Param Description Acceptable Values
propertySelector Chooses which value to select from the poll choices. count (number of choices), raw (return whole objects), index, points, title, votes
sortOrder Changes the sorting order to allow for index (default) and total votes sorting. "votes" for totalVotes DESC; anything else: index ASC sort.
desiredIndex Select which poll choice item to return using 1-based indexing. 0/null (returns all elements), or a number between 1-5 to get choice index 0-4.

Here's a few $pollChoices use cases:

Usage Description Example Use Case
$pollChoices[count] Gets the count of choices listed. There were 4 choices available in the poll.
$pollChoices[votes, votes, 1] Gets the number of votes cast for the most-voted item. Option x won with 173 votes cast for it.
$pollChoices[index, votes, 1] Gets the 1-based index of the most-voted item. Option 2 won with x votes cast for it.
$pollChoices[votes, index, 1] Gets the number of votes cast for the first item. Option 1 received 18 votes cast for it.
$pollChoices[points] Gets an array of point votes used on all items. There were $math[$arrayJoin[$pollChoices[points], " + "]] total channel point votes cast on all options.

Complaints

  • Simulate event doesn't work with any of this, manual execution does. 🤷
  • 1-based array indexing is the devil, but does present a better UX.

Applicable Issues

#2348 (partial), #2732 (partial)

Testing

  • Tested just about everything I could, but I welcome a bigger hammer to smash this with.
  • However, I'm not affiliated, so a lot of this is out of my testing reach.

Screenshots

N/A

phroggster avatar Sep 03 '24 08:09 phroggster

would you mind adding "partially resolves #2348" into your applicable issues?

dennisrijsdijk avatar Sep 04 '24 11:09 dennisrijsdijk

image Noticed something when simulating event. The Choices header will show up empty due to the way the modal parses the manualMetadata. This is related to how manualMetadata is parsed internally.

dennisrijsdijk avatar Sep 04 '24 13:09 dennisrijsdijk

Some questions that came up as I looked into this PR further:

Can you expose the channel points vote cost? Can you expose channel points votes for the winning choice?

dennisrijsdijk avatar Sep 04 '24 20:09 dennisrijsdijk

Can you expose the channel points vote cost?

We could cache the poll started event data somewhere, then do maths with it, but we'd have to do so in the twurple poll started callback, not in our start poll effect. Otherwise, the information would be missing if the poll was externally started.

Can you expose channel points votes for the winning choice?

I've corrected my description: channel points votes is what the "points" property selector will give out. Twitch's event docs for this are so confusing though, so I'm honestly absolutely clueless as to what any of this means at a high level. Aren't all poll votes locked behind channel points now, and totalVotes essentially locked to channelPointsVotes in the event data?

phroggster avatar Sep 04 '24 21:09 phroggster

Aren't all poll votes locked behind channel points now, and totalVotes essentially locked to channelPointsVotes in the event data?

poll votes, I believe, are a combination between free votes, and channelPointsVotes

dennisrijsdijk avatar Sep 04 '24 21:09 dennisrijsdijk

Converting to a draft, while we get a similar interface ironed out with predictions.

phroggster avatar Sep 04 '24 22:09 phroggster

We now have simulate events functioning properly thanks to CKY. ~~Going to leave this as a draft until we get predictions alongside with similar functionality, but~~ I believe this is officially ready for merging.

phroggster avatar Sep 05 '24 21:09 phroggster

~~I retract my last comment. The manualMetadata change to get simulate event working broke manually running the events. Back to the drawing board....~~ Edit: #2784 fixes my complaint on this.

phroggster avatar Sep 05 '24 21:09 phroggster