CPH Methods are used for communication between Streamer.bot and your C# code. These methods can be used for a lot of things that can be done with Sub-Actions or for even a couple things that don't have Sub-Actions. E.g. you can run actions, send messages to Twitch/YouTube and even do OBS raw.
This is the return value of the method, this can be anything from void to string to a class or even an int. Most of the times you can ignore this but for some cases this can be useful
Docs 1:
bool ActionExists(string actionName);
Example 1:
bool actionExist = CPH.ActionExists("my action");
if (actionExist) {
CPH.LogInfo("Action exists");
} else {
CPH.LogInfo("Action doesn't exists");
}
Docs 2:
void Wait(int milliseconds);
Example 2:
// If the return value is `void` you can't put it in a C# variable
CPH.Wait(5000);
This is the name of the method
This is the datatype that this option should be in this can be everything like a string, int, bool, etc.
This is the name of the option, this isn't used in your code. This is just so you can see what should be in the place of the option
If the option is like this: string option = "value"
so it ends with = <value>
then you can remove the option if it's the same as the default value.
Docs 1:
bool RunAction(string actionName, bool runImmediately = true);
Example 1:
// As you see the `bool runImmediately = true` is removed here, because you may don't need to change the value of `runImmediately`
CPH.RunAction("my action");
Docs 2:
void ObsSetScene(string sceneName, int connection = 0);
Example 2:
// As you see the `int connection = 0` is removed here, because you might only have one connection so it doesn't matter
CPH.ObsSetScene("Camera Scene");
bool TwitchAddVip(string userName);
For full docs about the args[]
below go to this page
string user = args["userName"].ToString(); // This grabs the `userName` variable from the action, NOTE: if the variable doesn't exist the code will stop
bool vipSuccess = CPH.TwitchAddVip(user); // This adds the user as a vip and stores if it succeeds in `vipSuccess`
if (vipSuccess) { // Everything inside this if statement only runs if the user has successfully been added a vip
CPH.SendMessage($"Added {user} as a vip");
}