tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.55k stars 214 forks source link

Where can I find more information on the 'method' object for Subscription events? #390

Closed liquidvisual closed 4 years ago

liquidvisual commented 4 years ago

The docs mention a 'method' object. What properties are in this object? Is this documented anywhere?

client.on("subscription", (channel, username, method, message, userstate) => {
    // Do your stuff.
});

Cheers,

ghost commented 4 years ago

For a new sub its 'method' for resub it's 'methods' both follow the following format. I believe gift sub does as well. I did not find any documentation on these I just dropped my bot in a channel and logged them.

Edit: It is an object, the results are just from how I logged it.

var entries = Object.entries(method)
console.log(entries)

Prime Sub:

{ prime: true,
  plan: 'Prime',
  planName: 'Dr DisRespect' }

Tier 1:

{ prime: false,
  plan: '1000',
  planName: 'Dr DisRespect' }

Tier 2:

{ prime: false,
  plan: '2000',
  planName: 'Dr DisRespect' }

Tier 3:

{ prime: false,
  plan: '3000',
  planName: 'Dr DisRespect' }

(Editing to be objects instead of entries -Alca)

liquidvisual commented 4 years ago

Thanks so much @Typ3Castt, you've saved me a lot of time! :) It's weird that they're an array of arrays, of course Twitch didn't want to make it easy for us.

AlcaDesign commented 4 years ago

It's not an array of arrays, it's an object.

https://github.com/tmijs/tmi.js/blob/92d7ccff8cecf33bc28c1f40612228e01943a4ff/lib/client.js#L651

ghost commented 4 years ago

Sorry, I should have been more clear. That is just how I logged them. It's an object.

var entries = Object.entries(method)
console.log(entries)`