public TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward.CreateCustomRewardsRequest getCreateRequest() { TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward.CreateCustomRewardsRequest newRewardRequest = new TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward.CreateCustomRewardsRequest(); newRewardRequest.Title = title; newRewardRequest.Cost = cost; if (!string.IsNullOrEmpty(description)) { newRewardRequest.Prompt = description; } if (!string.IsNullOrEmpty(backgroundColor)) { newRewardRequest.BackgroundColor = backgroundColor; } if (maxPerUserPerStream >= 1) { newRewardRequest.MaxPerUserPerStream = maxPerUserPerStream; newRewardRequest.IsMaxPerUserPerStreamEnabled = true; } if (maxPerStream >= 1) { newRewardRequest.MaxPerStream = maxPerStream; newRewardRequest.IsMaxPerStreamEnabled = true; } if (globalCooldown >= 1) { newRewardRequest.GlobalCooldownSeconds = globalCooldown; newRewardRequest.IsGlobalCooldownEnabled = true; } newRewardRequest.ShouldRedemptionsSkipRequestQueue = autoFulfill; newRewardRequest.IsUserInputRequired = requireUserInput; newRewardRequest.IsEnabled = enabled; return(newRewardRequest); }
private bool checkCreateChannelPointRedemptionReward(out bool bAlreadyExists) { bAlreadyExists = false; Task <TwitchLib.Api.Helix.Models.ChannelPoints.GetCustomReward.GetCustomRewardsResponse> getRewardsTask = m_BotBrain.twitchAPI.Helix.ChannelPoints.GetCustomRewardAsync(m_BotBrain.ownerID); getRewardsTask.Wait(); if (getRewardsTask.Result != null) { foreach (TwitchLib.Api.Helix.Models.ChannelPoints.CustomReward curReward in getRewardsTask.Result.Data) { if (curReward.Title == m_config.rewardInfo.title) { bAlreadyExists = true; return(true); // Already exists } } } // Doesn't already exist, create it TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward.CreateCustomRewardsRequest createRewardRequest = new TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward.CreateCustomRewardsRequest(); createRewardRequest.Cost = m_config.rewardInfo.cost; createRewardRequest.Title = m_config.rewardInfo.title; createRewardRequest.Prompt = m_config.rewardInfo.description; createRewardRequest.BackgroundColor = m_config.rewardInfo.backgroundColor; createRewardRequest.IsEnabled = true; try { Task <TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward.CreateCustomRewardsResponse> createRewardTask = m_BotBrain.twitchAPI.Helix.ChannelPoints.CreateCustomRewardsAsync(m_BotBrain.ownerID, createRewardRequest); createRewardTask.Wait(); if (createRewardTask.Result == null) { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("raffleRewardCreateFail")); return(false); } else { return(true); // Successfully created } } catch (Exception e) { m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("raffleRewardCreateFail")); return(false); } }
public bool attemptAddRequest(jerpBot aBotBrain, out bool aAlreadyExists) { aAlreadyExists = false; if (!updateInfoTask(aBotBrain)) { try { TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward.CreateCustomRewardsRequest createRewardRequest = getCreateRequest(); Task <TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward.CreateCustomRewardsResponse> createRewardTask = aBotBrain.twitchAPI.Helix.ChannelPoints.CreateCustomRewardsAsync(aBotBrain.ownerID, createRewardRequest); createRewardTask.Wait(); if (createRewardTask.Result == null) { Console.WriteLine("Failed to create channel point reward named: " + title); return(false); } else { rewardID = createRewardTask.Result.Data[0].Id; return(true); // Successfully created } } catch (Exception e) { Console.WriteLine(string.Format("Exception when trying to create channel point reward named: \"{0}\": {1}", title, e.Message)); return(false); } } else { aAlreadyExists = true; return(true); // Already exists } }