Skip to content

Twitch rewards, chat, moderation and clips

C# methods for a Run C# code step. See C# methods for how to use them.

TwitchGetRewards

Lists every channel point reward of your channel, with title, cost, prompt, colour and whether it is on or paused. IsOurs tells you if Cuebot created it (only those can be changed).

List<TwitchReward> TwitchGetRewards()

Gives back: A list of rewards. Empty when Twitch said no (a warning goes to the log).

Example

var rewards = CPH.TwitchGetRewards();
CPH.LogInfo($"You have {rewards.Count} rewards");

EnableReward

Turns a channel point reward on, so viewers can see it. rewardId is the reward's id or title; empty means the reward that ran this action. Only works for rewards Cuebot created.

void EnableReward(string rewardId)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.EnableReward("Hydrate");

DisableReward

Turns a channel point reward off, so viewers no longer see it. rewardId is the reward's id or title; empty means the reward that ran this action. Only works for rewards Cuebot created.

void DisableReward(string rewardId)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.DisableReward("Hydrate");

PauseReward

Pauses a channel point reward. Viewers still see it but cannot redeem it. rewardId is the reward's id or title; empty means the reward that ran this action. Only works for rewards Cuebot created.

void PauseReward(string rewardId)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.PauseReward("Hydrate");

UnPauseReward

Unpauses a channel point reward, so viewers can redeem it again. rewardId is the reward's id or title; empty means the reward that ran this action. Only works for rewards Cuebot created.

void UnPauseReward(string rewardId)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.UnPauseReward("Hydrate");

UpdateRewardMaxPerStream

Sets how many times a reward can be redeemed in one stream, by everyone together. 0 means no limit. With additive true, it adds to the current limit. Only works for rewards Cuebot created.

void UpdateRewardMaxPerStream(string rewardId, long redeems, bool additive = false)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.UpdateRewardMaxPerStream("Hydrate", 20);

UpdateRewardMaxPerUserPerStream

Sets how many times each viewer can redeem a reward in one stream. 0 means no limit. With additive true, it adds to the current limit. Only works for rewards Cuebot created.

void UpdateRewardMaxPerUserPerStream(string rewardId, long redeems, bool additive = false)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.UpdateRewardMaxPerUserPerStream("Hydrate", 3);

TwitchRedemptionFulfill

Marks a viewer's redemption as done, so it leaves the reward queue. You need both the reward id and the redemption id (the %rewardId% and %redemptionId% of a reward trigger).

bool TwitchRedemptionFulfill(string rewardId, string redemptionId)

Gives back: true when it worked. False when an id is empty or Twitch said no.

Example

bool ok = CPH.TwitchRedemptionFulfill(args["rewardId"].ToString(), args["redemptionId"].ToString());
CPH.LogInfo($"Fulfilled: {ok}");

TwitchRedemptionCancel

Cancels a viewer's redemption and gives them their channel points back. You need both the reward id and the redemption id.

bool TwitchRedemptionCancel(string rewardId, string redemptionId)

Gives back: true when it worked. False when an id is empty or Twitch said no.

Example

bool ok = CPH.TwitchRedemptionCancel(args["rewardId"].ToString(), args["redemptionId"].ToString());
CPH.LogInfo($"Refunded: {ok}");

TwitchGetRewardCounter

Reads how many times a reward has been redeemed, as Cuebot counts it. rewardId is the reward's id or title; empty means the reward that ran this action. Resetting on go-live is set per reward on the Twitch page, so persisted is ignored.

TwitchRewardCounter? TwitchGetRewardCounter(string rewardId, bool persisted = true)

Gives back: The counter (Count is the number), or null when the reward was not found.

Example

var counter = CPH.TwitchGetRewardCounter("Hydrate");
CPH.LogInfo($"Hydrate used {counter?.Count} times");

TwitchGetRewardUserCounter

Reads how many times one viewer (by login name) has redeemed a reward. persisted is ignored.

TwitchRewardCounter? TwitchGetRewardUserCounter(string userLogin, string rewardId, bool persisted = true)

Gives back: The counter (Count is the number), or null when the reward or viewer was not found.

Example

var counter = CPH.TwitchGetRewardUserCounter("coolviewer", "Hydrate");
CPH.LogInfo($"coolviewer used it {counter?.Count} times");

TwitchGetRewardUserCounterById

Reads how many times one viewer (by Twitch user id) has redeemed a reward. persisted is ignored.

TwitchRewardCounter? TwitchGetRewardUserCounterById(string userId, string rewardId, bool persisted = true)

Gives back: The counter (Count is the number), or null when the id is empty or the reward or viewer was not found.

Example

var counter = CPH.TwitchGetRewardUserCounterById("12345678", "Hydrate");
CPH.LogInfo($"Used {counter?.Count} times");

TwitchGetRewardUserCounters

Lists every viewer's redemption count for one reward. Handy for a "top redeemers" message. persisted is ignored.

List<TwitchRewardCounter> TwitchGetRewardUserCounters(string rewardId, bool persisted = true)

Gives back: A list with one counter per viewer (user id, name and count). Empty when the reward was not found.

Example

var counters = CPH.TwitchGetRewardUserCounters("Hydrate");
var top = counters.OrderByDescending(c => c.Count).FirstOrDefault();
CPH.LogInfo($"Top: {top?.UserName} with {top?.Count}");

TwitchResetRewardCounter

Sets a reward's total redemption count back to 0. rewardId is the reward's id or title; empty means the reward that ran this action.

void TwitchResetRewardCounter(string rewardId)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.TwitchResetRewardCounter("Hydrate");

TwitchResetRewardUserCounters

Clears every viewer's redemption count for one reward. rewardId is the reward's id or title; empty means the reward that ran this action.

void TwitchResetRewardUserCounters(string rewardId)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.TwitchResetRewardUserCounters("Hydrate");

TwitchResetUserRewardCounter

Clears one viewer's (by Twitch user id) redemption count for one reward.

void TwitchResetUserRewardCounter(string rewardId, string userId)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.TwitchResetUserRewardCounter("Hydrate", "12345678");

TwitchResetUserRewardCounters

Clears one viewer's (by Twitch user id) redemption counts for every reward. persisted is ignored, but you must still pass it.

void TwitchResetUserRewardCounters(string userId, bool persisted)

Gives back: Nothing. If it fails, a warning goes to the log.

Example

CPH.TwitchResetUserRewardCounters("12345678", true);

TwitchReplyToMessage

Replies to one chat message, so it shows as a reply. replyId is the message's id (%messageId%). useBot sends with your bot; fallback uses your main account when the bot is not signed in.

bool TwitchReplyToMessage(string message, string replyId, bool useBot = true, bool fallback = true)

Gives back: true when Twitch accepted it. False when the message is empty or Twitch said no.

Example

bool ok = CPH.TwitchReplyToMessage("Good question!", args["messageId"].ToString());
CPH.LogInfo($"Replied: {ok}");

TwitchDeleteChatMessage

Deletes one chat message by its id. Your main account deletes it; bot is ignored.

bool TwitchDeleteChatMessage(string messageId, bool bot = true)

Gives back: true when it worked. False when the id is empty or Twitch said no.

Example

bool ok = CPH.TwitchDeleteChatMessage(args["messageId"].ToString());
CPH.LogInfo($"Deleted: {ok}");

TwitchClearChatMessages

Clears your whole Twitch chat. Your main account does it; bot is ignored.

bool TwitchClearChatMessages(bool bot = true)

Gives back: true when it worked. When Twitch refuses or is not signed in, it gives back false and writes a warning to the log.

Example

bool ok = CPH.TwitchClearChatMessages();
CPH.LogInfo($"Chat cleared: {ok}");

TwitchPinChatMessage

Pins a chat message (by its id) at the top of chat. duration is in seconds (30 to 1800); 0 keeps it pinned until the stream ends. bot is ignored.

bool TwitchPinChatMessage(string messageId, int duration = 0, bool bot = false)

Gives back: true when it worked. False when the id is empty or Twitch said no.

Example

bool ok = CPH.TwitchPinChatMessage(args["messageId"].ToString(), 120);
CPH.LogInfo($"Pinned: {ok}");

TwitchSendAndPinMessage

Sends a message from your main account and pins it right away. duration works like TwitchPinChatMessage (0 keeps it until the stream ends). bot is ignored.

bool TwitchSendAndPinMessage(string message, int duration = 0, bool bot = false)

Gives back: true when it worked. False when the message is empty or Twitch said no.

Example

bool ok = CPH.TwitchSendAndPinMessage("Giveaway: type !join to enter!", 300);
CPH.LogInfo($"Sent and pinned: {ok}");

TwitchUnpinMessage

Unpins the chat message that is pinned now.

bool TwitchUnpinMessage()

Gives back: true when it worked. False when nothing is pinned or Twitch said no.

Example

bool ok = CPH.TwitchUnpinMessage();
CPH.LogInfo($"Unpinned: {ok}");

TwitchUpdatePinnedMessageDuration

Changes how long the pinned message stays, counted from now, in seconds. 0 keeps it pinned until the stream ends.

bool TwitchUpdatePinnedMessageDuration(int duration)

Gives back: true when it worked. False when nothing is pinned or Twitch said no.

Example

bool ok = CPH.TwitchUpdatePinnedMessageDuration(600);
CPH.LogInfo($"Pin time changed: {ok}");

TwitchGetPinnedMessage

Reads the chat message that is pinned now: its text, who wrote it, who pinned it, and when the pin started and ends.

TwitchPinnedMessage? TwitchGetPinnedMessage()

Gives back: The pinned message, or null when nothing is pinned or the check failed.

Example

var pin = CPH.TwitchGetPinnedMessage();
CPH.LogInfo(pin == null ? "Nothing pinned" : $"Pinned: {pin.Message}");

TwitchWarnUser

Sends a viewer (by login name) a Twitch warning with your reason. They must accept it before they can chat again. useBot is ignored.

bool TwitchWarnUser(string userName, string reason, bool useBot = false)

Gives back: true when it worked. False when the name is empty or Twitch said no.

Example

bool ok = CPH.TwitchWarnUser("rudeviewer", "Please keep chat friendly.");
CPH.LogInfo($"Warned: {ok}");

TwitchAddActiveMonitoringSuspiciousStatus

Puts a viewer (by Twitch user id) under active monitoring. Their messages get flagged for your moderators.

bool TwitchAddActiveMonitoringSuspiciousStatus(string userId)

Gives back: true when it worked. False when the id is empty or Twitch said no.

Example

bool ok = CPH.TwitchAddActiveMonitoringSuspiciousStatus("12345678");
CPH.LogInfo($"Monitoring: {ok}");

TwitchAddRestrictedSuspiciousStatus

Restricts a viewer (by Twitch user id). Their messages are kept out of chat; only moderators see them.

bool TwitchAddRestrictedSuspiciousStatus(string userId)

Gives back: true when it worked. False when the id is empty or Twitch said no.

Example

bool ok = CPH.TwitchAddRestrictedSuspiciousStatus("12345678");
CPH.LogInfo($"Restricted: {ok}");

TwitchRemoveSuspiciousStatus

Removes the monitored or restricted status from a viewer (by Twitch user id).

bool TwitchRemoveSuspiciousStatus(string userId)

Gives back: true when it worked. False when the id is empty or Twitch said no.

Example

bool ok = CPH.TwitchRemoveSuspiciousStatus("12345678");
CPH.LogInfo($"Status removed: {ok}");

TwitchAddBlockedTerm

Adds a word or phrase to your channel's blocked terms. Messages with it are kept out of chat.

bool TwitchAddBlockedTerm(string term)

Gives back: true when it worked. False when the term is empty or Twitch said no.

Example

bool ok = CPH.TwitchAddBlockedTerm("spoiler");
CPH.LogInfo($"Term blocked: {ok}");

TwitchRemoveBlockedTerm

Removes a word or phrase from your blocked terms. Type it as it was added; upper and lower case do not matter.

bool TwitchRemoveBlockedTerm(string term)

Gives back: true when it was removed. False when your channel has no such term, the term is empty, or Twitch said no.

Example

bool ok = CPH.TwitchRemoveBlockedTerm("spoiler");
CPH.LogInfo($"Term removed: {ok}");

TwitchGetBlockedTerms

Lists every blocked word or phrase of your channel.

List<string> TwitchGetBlockedTerms()

Gives back: A list of texts. Empty when Twitch said no (a warning goes to the log).

Example

var terms = CPH.TwitchGetBlockedTerms();
CPH.LogInfo($"Blocked: {string.Join(", ", terms)}");

TwitchApproveAutoHeldMessage

Lets a message through that AutoMod held back for review. Pass the held message's id.

bool TwitchApproveAutoHeldMessage(string messageId)

Gives back: true when it worked. False when the id is empty or Twitch said no.

Example

bool ok = CPH.TwitchApproveAutoHeldMessage(args["messageId"].ToString());
CPH.LogInfo($"Approved: {ok}");

TwitchDenyAutoHeldMessage

Blocks a message that AutoMod held back for review, so it never shows in chat.

bool TwitchDenyAutoHeldMessage(string messageId)

Gives back: true when it worked. False when the id is empty or Twitch said no.

Example

bool ok = CPH.TwitchDenyAutoHeldMessage(args["messageId"].ToString());
CPH.LogInfo($"Denied: {ok}");

TwitchGetMods

Lists every moderator of your channel, with their id, login name and display name.

List<TwitchUserInfo> TwitchGetMods()

Gives back: A list of users. Empty when Twitch said no (a warning goes to the log).

Example

var mods = CPH.TwitchGetMods();
CPH.LogInfo($"You have {mods.Count} mods");

TwitchGetVips

Lists every VIP of your channel, with their id, login name and display name.

List<TwitchUserInfo> TwitchGetVips()

Gives back: A list of users. Empty when Twitch said no (a warning goes to the log).

Example

var vips = CPH.TwitchGetVips();
CPH.LogInfo($"VIPs: {string.Join(", ", vips.Select(v => v.UserName))}");

GetCheermotes

Lists the cheermotes (Bits emotes like Cheer100) your channel can use, with their tiers, colours and image links.

List<Cheermote> GetCheermotes()

Gives back: A list of cheermotes. Empty when Twitch said no.

Example

var cheermotes = CPH.GetCheermotes();
CPH.LogInfo($"First cheermote: {cheermotes.FirstOrDefault()?.Prefix}");

TwitchBlockUser

Not supported in Cuebot: Cuebot does not ask Twitch for permission to block users. It only writes a warning to the log.

bool TwitchBlockUser(string userLogin, TwitchBlockContext context = TwitchBlockContext.None, TwitchBlockReason reason = TwitchBlockReason.None)

Gives back: Always false.

Example

bool ok = CPH.TwitchBlockUser("spammer123");
CPH.LogInfo($"Blocked: {ok}");

TwitchBlockUserById

Not supported in Cuebot: Cuebot does not ask Twitch for permission to block users. It only writes a warning to the log.

bool TwitchBlockUserById(string userId, TwitchBlockContext context = TwitchBlockContext.None, TwitchBlockReason reason = TwitchBlockReason.None)

Gives back: Always false.

Example

bool ok = CPH.TwitchBlockUserById("12345678");
CPH.LogInfo($"Blocked: {ok}");

GetAllClips

Lists the clips of your own channel. Clips come most viewed first, at most 1000. isFeatured true gives only featured clips, false only the others, and leaving it out gives both.

List<ClipData> GetAllClips(bool? isFeatured = null)

Gives back: A list of clips (link, title, views, creator and more). Empty when Twitch said no.

Example

var clips = CPH.GetAllClips();
CPH.LogInfo($"You have {clips.Count} clips");

GetClips

Lists your own channel's most viewed clips, up to count clips (at least 1). isFeatured true gives only featured clips, false only the others.

List<ClipData> GetClips(int count, bool? isFeatured = null)

Gives back: A list of clips. Empty when Twitch said no.

Example

var clips = CPH.GetClips(5);
CPH.LogInfo($"Top clip: {clips.FirstOrDefault()?.Url}");

GetClipsForGame

Lists clips of one game or category from all of Twitch, using the game's Twitch id. Other versions add how many clips, a start and end time, or a time span back from now (like the last 7 days).

List<ClipData> GetClipsForGame(int gameId, bool? isFeatured = null)
List<ClipData> GetClipsForGame(int gameId, int count, bool? isFeatured = null)
List<ClipData> GetClipsForGame(int gameId, DateTime start, DateTime end, bool? isFeatured = null)
List<ClipData> GetClipsForGame(int gameId, DateTime start, DateTime end, int count, bool? isFeatured = null)
List<ClipData> GetClipsForGame(int gameId, TimeSpan duration, bool? isFeatured = null)
List<ClipData> GetClipsForGame(int gameId, TimeSpan duration, int count, bool? isFeatured = null)

Gives back: A list of clips, most viewed first. Empty when Twitch said no.

Example

var clips = CPH.GetClipsForGame(509658, TimeSpan.FromDays(7), 5);
CPH.LogInfo($"Top clip this week: {clips.FirstOrDefault()?.Title}");

GetClipsForUser

Lists clips of another channel, by login name or by user id as a number. Other versions add how many clips, a start and end time, or a time span back from now. Great for a shoutout that plays a clip.

List<ClipData> GetClipsForUser(string username, bool? isFeatured = null)
List<ClipData> GetClipsForUser(string userName, int count, bool? isFeatured = null)
List<ClipData> GetClipsForUser(string username, DateTime start, DateTime end, bool? isFeatured = null)
List<ClipData> GetClipsForUser(string username, DateTime start, DateTime end, int count, bool? isFeatured = null)
List<ClipData> GetClipsForUser(string username, TimeSpan duration, bool? isFeatured = null)
List<ClipData> GetClipsForUser(string username, TimeSpan duration, int count, bool? isFeatured = null)
List<ClipData> GetClipsForUser(int userId, bool? isFeatured = null)
List<ClipData> GetClipsForUser(int userId, int count, bool? isFeatured = null)
List<ClipData> GetClipsForUser(int userId, DateTime start, DateTime end, bool? isFeatured = null)
List<ClipData> GetClipsForUser(int userId, DateTime start, DateTime end, int count, bool? isFeatured = null)
List<ClipData> GetClipsForUser(int userId, TimeSpan duration, bool? isFeatured = null)
List<ClipData> GetClipsForUser(int userId, TimeSpan duration, int count, bool? isFeatured = null)

Gives back: A list of clips, most viewed first. Empty when the name is empty or Twitch said no.

Example

var clips = CPH.GetClipsForUser("coolstreamer", 1);
CPH.LogInfo($"Their top clip: {clips.FirstOrDefault()?.Url}");

GetClipsForUserById

Lists clips of another channel by its Twitch user id (as text). Other versions add how many clips, a start and end time, or a time span back from now.

List<ClipData> GetClipsForUserById(string userId, bool? isFeatured = null)
List<ClipData> GetClipsForUserById(string userId, int count, bool? isFeatured = null)
List<ClipData> GetClipsForUserById(string userId, DateTime start, DateTime end, bool? isFeatured = null)
List<ClipData> GetClipsForUserById(string userId, DateTime start, DateTime end, int count, bool? isFeatured = null)
List<ClipData> GetClipsForUserById(string userId, TimeSpan duration, bool? isFeatured = null)
List<ClipData> GetClipsForUserById(string userId, TimeSpan duration, int count, bool? isFeatured = null)

Gives back: A list of clips, most viewed first. Empty when the id is empty or Twitch said no.

Example

var clips = CPH.GetClipsForUserById("12345678", TimeSpan.FromDays(30), 3);
CPH.LogInfo($"Found {clips.Count} clips");