Faq

User In Group

How do I check whether a user is in a group?

Since version 0.2.3, platform-specific group sub-actions have been introduced, accessible in the context menu under User Groups. If you want to check whether a Twitch user is in a group via sub-actions, navigate to Twitch -> User Groups -> User In Group. You can either input a direct username or use a variable such as %userName% or %targetUserName%, followed by the group name. The sub-action will generate a variable called inGroup, which you can utilize in an if/else sub-action (if inGroup Equals True continue, else break).

This can also be done in C#. Create a subaction Core -> C# -> Execute C# Code) and paste the code below in there. Replace group1 with the name of your group. Hit Save and Compile afterwards. This will provide the %inGroup% variable, that you can then check against in an if/else-subaction (if inGroup equals True continue, else break). Since 0.2.3, all C# group methods require a platform property, like shown below in the code example.

After 0.2.3

using System;

public class CPHInline
{
    public bool Execute()
    {
        Platform platform = Platform.Twitch; 
        string userId = args["userId"].ToString();
        string groupName = "group1";
        bool inGroup = CPH.UserIdInGroup(userId, platform, groupName);
        CPH.SetArgument("inGroup",inGroup);
        return true;
    }
}

Before 0.2.3

using System;

public class CPHInline
{
    public bool Execute()
    {
        string userId = args["userId"].ToString();
        string groupName = "group1";
        bool inGroup = CPH.UserIdInGroup(userId,groupName);
        CPH.SetArgument("inGroup",inGroup);
        return true;
    }
}