GetTwitchUsersVar

Get a list of all Twitch users with a given variable, along with their values

Signature

public List<UserVariableValue<T>> GetTwitchUsersVar<T>(string varName, bool persisted = true)

Parameters

varName
string required

The string name of the global variable

persisted
bool
Default:
True

To get, set, or unset persisted global variables, set to true or leave empty.

To get, set, or unset temporary/non-persisted global variables, set to false.

Return Type

List<UserVariableValue<T>>

Example

using System;
using System.Collections.Generic; //Needed cause of List<> usage

public class CPHInline
{
    public bool Execute()
    {
        //Get the user var list which is a List of type UserVariableValue with a specific type
        List<UserVariableValue<long>> userVarList = CPH.GetTwitchUsersVar<long>("userVar", true); 
        //For each loop which prints infos into Log File of the userVarList
        foreach(UserVariableValue<long> userVar in userVarList)
        {
            string displayName = userVar.UserName;
            string userId = userVar.UserId;
            string userLogin = userVar.UserLogin;

            //Actual value of user variable must be of same type previousy defined
            long value = userVar.Value;

            //Last time the user var was updated for the user
            DateTime lastUpdate = userVar.LastWrite;

            CPH.LogInfo($"{displayName} - {userId} - {userLogin} - {value} - {lastUpdate}");
        }
        return true;
    }
}