/// <summary> /// Creates the Swap Players custom reward created on the channel using /// the CreateCustomRewards API. /// </summary> public Task <CustomReward> CreateSwapPlayersReward() { var swapReward = new CreateCustomRewardsRequest(); swapReward.Title = Constants.SwapPlayersString; swapReward.Cost = 500; swapReward.Prompt = "Swap players with each other randomly"; swapReward.IsEnabled = true; swapReward.IsUserInputRequired = false; swapReward.IsGlobalCooldownEnabled = true; swapReward.GlobalCooldownSeconds = 10; return(CreateCustomReward(swapReward)); }
/// <summary> /// Creates the Kill Random Player custom reward on the channel using /// the CreateCustomRewards API. /// </summary> public Task <CustomReward> CreateRandomKillPlayerReward() { var randomKillReward = new CreateCustomRewardsRequest(); randomKillReward.Title = Constants.KillRandomPlayerString; randomKillReward.Cost = 1000; randomKillReward.Prompt = "Kills a Random Player"; randomKillReward.IsEnabled = true; randomKillReward.IsUserInputRequired = false; randomKillReward.IsGlobalCooldownEnabled = true; randomKillReward.GlobalCooldownSeconds = 60; return(CreateCustomReward(randomKillReward)); }
/// <summary> /// Creates the Kill Player custom reward on the channel using /// the CreateCustomRewards API. /// </summary> public Task <CustomReward> CreateKillPlayerReward() { var killReward = new CreateCustomRewardsRequest(); killReward.Title = Constants.KillPlayerString; killReward.Cost = 1000; killReward.Prompt = "Name a player to kill: "; killReward.IsEnabled = false; killReward.IsUserInputRequired = true; killReward.IsGlobalCooldownEnabled = true; killReward.GlobalCooldownSeconds = 10; return(CreateCustomReward(killReward)); }
public CustomReward(CreateCustomRewardsRequest from) { Id = Guid.NewGuid().ToString(); Title = from.Title; Prompt = from.Prompt; Cost = from.Cost; IsEnabled = from.IsEnabled; BackgroundColor = from.BackgroundColor; IsUserInputRequired = from.IsUserInputRequired; // IsMaxPerStreamEnabled = from.IsMaxPerStreamEnabled; // MaxPerStream = from.MaxPerStream; // IsMaxPerUserPerStreamEnabled = from.IsMaxPerUserPerStreamEnabled; // MaxPerUserPerStream = from.MaxPerUserPerStream; // IsGlobalCooldownEnabled = from.IsGlobalCooldownEnabled; // GlobalCooldownSeconds = from.GlobalCooldownSeconds; ShouldRedemptionsSkipQueue = from.ShouldRedemptionsSkipRequestQueue; }
/// <summary> /// Creates the custom reward if it does not exist already. /// See the Twitch API documentation at /// https://dev.twitch.tv/docs/api/reference#create-custom-rewards /// for more info. /// </summary> public async Task <CustomReward> CreateCustomReward(CreateCustomRewardsRequest reward) { try { var response = await API.Helix.ChannelPoints.CreateCustomRewards( this.channelId, reward, this.accessToken); _logger.Information($"Reward for ${response.Data[0].Title} has been added with the RewardId = {response.Data[0].Id}"); return(response.Data[0]); } catch (InvalidCredentialException e) { _logger.Information($"{e.Message}"); await RefreshAccessToken(); return(await CreateCustomReward(reward)); } catch (Exception e) { _logger.Error($"{e.Message}"); throw e; } }
public Task <CreateCustomRewardsResponse> CreateCustomRewards(string broadcasterId, CreateCustomRewardsRequest request, string accessToken = null) { var getParams = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("broadcaster_id", broadcasterId) }; return(TwitchPostGenericAsync <CreateCustomRewardsResponse>("/channel_points/custom_rewards", ApiVersion.Helix, JsonConvert.SerializeObject(request), getParams, accessToken)); }