Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Channel Points Automatic Reward Redemption #34

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
using TwitchLib.EventSub.Websockets.Core.Models;

namespace TwitchLib.EventSub.Websockets.Core.EventArgs.Channel;

public class ChannelPointsAutomaticRewardRedemptionArgs : TwitchLibEventSubEventArgs<EventSubNotification<ChannelPointsAutomaticRewardRedemption>>
{
}
5 changes: 5 additions & 0 deletions TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
/// <summary>
/// Event that triggers on "channel.charity_campaign.donate" notifications
/// </summary>
public event AsyncEventHandler<ChannelCharityCampaignDonateArgs> ChannelCharityCampaignDonate;

Check warning on line 66 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelCharityCampaignDonate' is never used
/// <summary>
/// Event that triggers on "channel.charity_campaign.progress" notifications
/// </summary>
Expand All @@ -71,7 +71,7 @@
/// <summary>
/// Event that triggers on "channel.charity_campaign.stop" notifications
/// </summary>
public event AsyncEventHandler<ChannelCharityCampaignStopArgs> ChannelCharityCampaignStop;

Check warning on line 74 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelCharityCampaignStop' is never used
/// <summary>
/// Event that triggers on channel.chat.message notifications
/// </summary>
Expand All @@ -83,12 +83,12 @@
/// <summary>
/// Event that triggers on "channel.follow" notifications
/// </summary>
public event AsyncEventHandler<ChannelFollowArgs> ChannelFollow;

Check warning on line 86 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelFollow' is never used

/// <summary>
/// Event that triggers on "channel.goal.begin" notifications
/// </summary>
public event AsyncEventHandler<ChannelGoalBeginArgs> ChannelGoalBegin;

Check warning on line 91 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelGoalBegin' is never used
/// <summary>
/// Event that triggers on "channel.goal.end" notifications
/// </summary>
Expand All @@ -105,7 +105,7 @@
/// <summary>
/// Event that triggers on "channel.guest_star_session.begin" notifications
/// </summary>
public event AsyncEventHandler<ChannelGuestStarSessionBegin> ChannelGuestStarSessionBegin;

Check warning on line 108 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelGuestStarSessionBegin' is never used
/// <summary>
/// Event that triggers on "channel.guest_star_guest.update" notifications
/// </summary>
Expand All @@ -130,7 +130,7 @@
/// <summary>
/// Event that triggers on "channel.hype_train.progress" notifications
/// </summary>
public event AsyncEventHandler<ChannelHypeTrainProgressArgs> ChannelHypeTrainProgress;

Check warning on line 133 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelHypeTrainProgress' is never used

/// <summary>
/// Event that triggers on "channel.moderator.add" notifications
Expand Down Expand Up @@ -163,6 +163,11 @@
/// </summary>
public event AsyncEventHandler<ChannelPointsCustomRewardArgs> ChannelPointsCustomRewardUpdate;

/// <summary>
/// Event that triggers on "channel.channel_points_automatic_reward_redemption.add" notifications
/// </summary>
public event AsyncEventHandler<ChannelPointsAutomaticRewardRedemptionArgs> ChannelPointsAutomaticRewardRedemptionAdd;

/// <summary>
/// Event that triggers on "channel.channel_points_custom_reward_redemption.add" notifications
/// </summary>
Expand All @@ -170,7 +175,7 @@
/// <summary>
/// Event that triggers on "channel.channel_points_custom_reward_redemption.update" notifications
/// </summary>
public event AsyncEventHandler<ChannelPointsCustomRewardRedemptionArgs> ChannelPointsCustomRewardRedemptionUpdate;

Check warning on line 178 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelPointsCustomRewardRedemptionUpdate' is never used

/// <summary>
/// Event that triggers on "channel.poll.begin" notifications
Expand All @@ -179,7 +184,7 @@
/// <summary>
/// Event that triggers on "channel.poll.end" notifications
/// </summary>
public event AsyncEventHandler<ChannelPollEndArgs> ChannelPollEnd;

Check warning on line 187 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelPollEnd' is never used
/// <summary>
/// Event that triggers on "channel.poll.progress" notifications
/// </summary>
Expand All @@ -200,7 +205,7 @@
/// <summary>
/// Event that triggers on "channel.prediction.progress" notifications
/// </summary>
public event AsyncEventHandler<ChannelPredictionProgressArgs> ChannelPredictionProgress;

Check warning on line 208 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelPredictionProgress' is never used

/// <summary>
/// Event that triggers on "channel.raid" notifications
Expand Down Expand Up @@ -250,7 +255,7 @@
/// <summary>
/// Event that triggers on "channel.update" notifications
/// </summary>
public event AsyncEventHandler<ChannelUpdateArgs> ChannelUpdate;

Check warning on line 258 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelUpdate' is never used

/// <summary>
/// Event that triggers on "stream.offline" notifications
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Text.Json;
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
using TwitchLib.EventSub.Websockets.Core.EventArgs;
using TwitchLib.EventSub.Websockets.Core.EventArgs.Channel;
using TwitchLib.EventSub.Websockets.Core.Handler;
using TwitchLib.EventSub.Websockets.Core.Models;

namespace TwitchLib.EventSub.Websockets.Handler.Channel.ChannelPoints.Redemptions;
/// <summary>
/// Handler for 'channel.channel_points_automatic_reward_redemption.add' notifications
/// </summary>
public class ChannelPointsAutomaticRewardRedemptionAddHandler : INotificationHandler
{
/// <inheritdoc />
public string SubscriptionType => "channel.channel_points_automatic_reward_redemption.add";

/// <inheritdoc />
public void Handle(EventSubWebsocketClient client, string jsonString, JsonSerializerOptions serializerOptions)
{
try
{
var data = JsonSerializer.Deserialize<EventSubNotification<ChannelPointsAutomaticRewardRedemption>>(jsonString.AsSpan(), serializerOptions);

if (data is null)
throw new InvalidOperationException("Parsed JSON cannot be null!");

client.RaiseEvent("ChannelPointsAutomaticRewardRedemptionAdd", new ChannelPointsAutomaticRewardRedemptionArgs { Notification = data });
}
catch (Exception ex)
{
client.RaiseEvent("ErrorOccurred", new ErrorOccuredArgs { Exception = ex, Message = $"Error encountered while trying to handle {SubscriptionType} notification! Raw Json: {jsonString}" });
}
}
}
Loading