Skip to content

Commit

Permalink
Add Sub Logging to hopefully debug eventsub issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
LordTocs committed Jul 13, 2024
1 parent 12ed14a commit 059dd81
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion plugins/twitch/main/src/subscriptions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { ApiClient } from "@twurple/api"
import { EventSubWsListener } from "@twurple/eventsub-ws"
import { TwitchAccount } from "./twitch-auth"
import { defineState, defineTrigger } from "castmate-core"
import { defineState, defineTrigger, usePluginLogger } from "castmate-core"
import { Range } from "castmate-schema"
import { TwitchAPIService, onChannelAuth } from "./api-harness"
import { ViewerCache } from "./viewer-cache"
import { TwitchViewer, TwitchViewerGroup } from "castmate-plugin-twitch-shared"
import { inTwitchViewerGroup } from "./group"

export function setupSubscriptions() {
const logger = usePluginLogger()

const subscription = defineTrigger({
id: "subscription",
name: "Subscriber",
Expand Down Expand Up @@ -123,6 +125,16 @@ export function setupSubscriptions() {
})

service.eventsub.onChannelSubscriptionMessage(channel.twitchId, async (event) => {
logger.log(
"Sub Message Received: ",
event.userDisplayName,
event.userId,
event.tier,
event.cumulativeMonths,
event.durationMonths,
event.streakMonths
)

let tier = 1
if (event.tier == "2000") {
tier = 2
Expand Down

0 comments on commit 059dd81

Please sign in to comment.