2 years ago

Oki I got the backend for the Twitch Overlay Outfit Switching done :3

I will explain exactly how it works in the Article owO

Note that I will not be going into how to set up any of the Initial Websocket stuff,,


ok so we subscribe to channel.poll.end (to get a websocket notification of the poll results)

by sending a request to

https://api.twitch.tv/helix/eventsub/subscriptions

with the data looking something like this,,

image.png

and we also have to put channel:manage:polls in our websocket authorization scopes :3

now when someone redeems this Reward:

image.png

we send a request to https://api.twitch.tv/helix/polls

with the data looking something like this:

{"broadcaster_id":"123456","title":"Streaming next Tuesday. Which time works best for you?","choices":[{"title":"9AM"},{"title":"10AM"},{"title":"7PM"},{"title":"8PM"},{"title":"9PM"}],"duration":300}

(directly taken from twitch's documentation)

the headers are ofc as always

["Authorization: Bearer 'token'", "Client-id: 'clientid'", "Content-Type: application/json"]

all of that STARTS a poll,, since we subscribed to the channel.poll.end websocket notification, we just have to wait for that, which is under "metadata" / "subscription_type" in the response.

which is well,, gonna be "channel.poll.end" on the end of a poll... then we just do this...

image.png

which basically just puts the results INDIVIDUALLY into an array and then uses a custom sort algorithm on it (from most to least)

then we take the first result voteresult[0] which gives us something like [amount_of_votes, "Choice Name"]

then we get [1] on that, to get the name :3 and that's all uwu



3 comments

Loading...

Next up

Ha! Heh! Heh! Ha! It's over!

Working more on Orphan Simulator, progress is coming along very, very well! Everyone think's Jack is directly based off Jevil, but truth be told it was completely coincidence and I just wanted to make a funny jack in the box enemy.

My aseprite tree generator is finally out and panicking!

get the extension here: https://devkidd.itch.io/gentree

#aseprite #pixelart #gamedev #indiegame #indiedev

Heya there! I really wanted to show you all a little gameplay preview of the first boss fight i'm currently working on i hope you like it ^^

Shadow The Hedgehog X pixel art

Updated the chest in the maze, adding sound, particles and better animation. But what's in the chest?

The whole squad is here!

Interested? Follow me!

A Shiny Mega Gengar ๐ŸŒŸ For @ManutkArt 's #ThreeColorsChallenge!

Call it 'wrong turn'!๐Ÿšซ The feeling of running into a house with only one exit๐Ÿšช, and being doomed to die. #pixelart #pixelartist #pixelartwork #art #pixel #indiegame #IndieGameDev #indieartist

Rockin the Guitar, an Axe like Guitar I made for my Uni project