feat (vars): Add $pollTitle and $pollChoices Variables
Description of the Change
- Add a
$pollTitlevariable that provides the name of a poll being started, updated, and/or ended. - Add a
$pollChoicesvariable that can return any piece of information about poll choices for the same event types without requiring$objectWalkPathor$arrayElement-style walking:. - Raw
$pollChoiceswill yield an array of the choices available (withid,index,points,title,votesproperties), 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
would you mind adding "partially resolves #2348" into your applicable issues?
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.
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?
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?
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
Converting to a draft, while we get a similar interface ironed out with predictions.
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.
~~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.