diff --git a/package.json b/package.json index cd6e4fa9583..cca3d48c291 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,12 @@ "license": "MIT", "dependencies": { "@d-fischer/shared-utils": "^3.6.3", - "@twurple/api": "7.0.6", - "@twurple/auth": "7.0.6", - "@twurple/chat": "7.0.6", - "@twurple/eventsub-base": "^7.0.6", - "@twurple/eventsub-ws": "7.0.6", - "@twurple/pubsub": "7.0.6", + "@twurple/api": "7.0.10", + "@twurple/auth": "7.0.10", + "@twurple/chat": "7.0.10", + "@twurple/eventsub-base": "^7.0.10", + "@twurple/eventsub-ws": "7.0.10", + "@twurple/pubsub": "7.0.10", "async-mutex": "^0.4.0", "axios": "1.6.2", "basic-auth": "2.0.1", diff --git a/src/events.ts b/src/events.ts index de8d7cef810..0e5ff6de4f2 100644 --- a/src/events.ts +++ b/src/events.ts @@ -146,7 +146,7 @@ class Events extends Core { { id: 'follow', variables: [ 'username', 'is.moderator', 'is.subscriber', 'is.vip', 'is.broadcaster', 'is.bot', 'is.owner' ] }, { id: 'subscription', variables: [ 'username', 'is.moderator', 'is.subscriber', 'is.vip', 'is.broadcaster', 'is.bot', 'is.owner', 'method', 'subCumulativeMonths', 'tier' ] }, { id: 'subgift', variables: [ 'username', 'is.moderator', 'is.subscriber', 'is.vip', 'is.broadcaster', 'is.bot', 'is.owner', 'recipient', 'recipientis.moderator', 'recipientis.subscriber', 'recipientis.vip', 'recipientis.broadcaster', 'recipientis.bot', 'recipientis.owner', 'tier' ] }, - { id: 'subcommunitygift', variables: [ 'username', 'count' ] }, + { id: 'subcommunitygift', variables: [ 'username', 'count', 'tier' ] }, { id: 'resub', variables: [ 'username', 'is.moderator', 'is.subscriber', 'is.vip', 'is.broadcaster', 'is.bot', 'is.owner', 'subStreakShareEnabled', 'subStreak', 'subStreakName', 'subCumulativeMonths', 'subCumulativeMonthsName', 'tier', 'message' ] }, { id: 'tip', variables: [ 'username', 'amount', 'currency', 'message', 'amountInBotCurrency', 'currencyInBot' ] }, { diff --git a/src/helpers/events/emitter.ts b/src/helpers/events/emitter.ts index b78b0b755aa..af3f206d2e7 100644 --- a/src/helpers/events/emitter.ts +++ b/src/helpers/events/emitter.ts @@ -1,6 +1,7 @@ import { EventSubChannelGoalType } from '@twurple/eventsub-base/lib/events/common/EventSubChannelGoalType'; import { TypedEmitter } from 'tiny-typed-emitter'; +import { EmitData } from '~/database/entity/overlay.js'; import { Types } from '~/plugins/ListenTo.js'; export interface Events { @@ -58,7 +59,7 @@ export interface Events { 'cheer': (opts: {userName: string, userId: string, bits: number, message: string}) => void; 'user-joined-channel': (opts: {userName: string}) => void; 'user-parted-channel': (opts: {userName: string}) => void; - 'subcommunitygift': (opts: {userName: string; count: number}) => void; + 'subcommunitygift': (opts: {userName: string; count: number, tier: EmitData['tier']}) => void; 'reward-redeemed': (opts: {userId: string; userName: string; rewardId: string; userInput: string;}) => void; 'timeout': (opts: {userName: string; duration: number}) => void; 'ban': (opts: {userName: string; reason: string}) => void; @@ -66,15 +67,15 @@ export interface Events { 'highlight': (opts: {userId: string, message: string}) => void; 'stream-started': () => void; 'stream-stopped': () => void; - 'subscription': (opts: { userName: string; method: string; subCumulativeMonths: number; tier: string}) => void; - 'resub': (opts: { userName: string; subStreakShareEnabled: boolean, subStreak: number; subStreakName: string; subCumulativeMonthsName: string; message: string; subCumulativeMonths: number; tier: string}) => void; + 'subscription': (opts: { userName: string; method: string; subCumulativeMonths: number; tier: EmitData['tier']}) => void; + 'resub': (opts: { userName: string; subStreakShareEnabled: boolean, subStreak: number; subStreakName: string; subCumulativeMonthsName: string; message: string; subCumulativeMonths: number; tier: EmitData['tier']}) => void; 'clearchat': () => void; 'command-send-x-times': (opts: { reset: boolean } | { userName: string, message: string, source: 'discord' | 'twitch' }) => void; 'keyword-send-x-times': (opts: { reset: boolean } | { userName: string, message: string, source: 'discord' | 'twitch' }) => void; 'chatter-first-message': (opts: { userName: string, message: string, source: 'twitch' }) => void; 'every-x-minutes-of-stream': (opts: { reset: boolean }) => void; 'stream-is-running-x-minutes': (opts: { reset: boolean }) => void; - 'subgift': (opts: { userName: string; recipient: string; tier: number; }) => void; + 'subgift': (opts: { userName: string; recipient: string; tier: EmitData['tier']; }) => void; 'number-of-viewers-is-at-least-x': (opts: { reset: boolean }) => void; 'tip': (opts: { isAnonymous: boolean, userName: string, amount: string; currency: string; amountInBotCurrency: string; currencyInBot: string; message: string; }) => void; // OBS Websocket integration diff --git a/src/helpers/events/subscription.ts b/src/helpers/events/subscription.ts index 29fcd12ed66..ee171ff67fd 100644 --- a/src/helpers/events/subscription.ts +++ b/src/helpers/events/subscription.ts @@ -65,7 +65,7 @@ export const subscription = async (username: string , subInfo: ChatSubInfo, user }); sub(`${username}#${userstate.userId}, tier: ${tier}`); eventEmitter.emit('subscription', { - userName: username, method: subInfo.isPrime ? 'Twitch Prime' : '', subCumulativeMonths: amount, tier: String(tier), + userName: username, method: subInfo.isPrime ? 'Twitch Prime' : '', subCumulativeMonths: amount, tier, }); alerts.trigger({ eventId: eventData?.id ?? null, diff --git a/src/services/twitch/chat.ts b/src/services/twitch/chat.ts index 14719ff7db8..ceb32338ee6 100644 --- a/src/services/twitch/chat.ts +++ b/src/services/twitch/chat.ts @@ -487,7 +487,7 @@ class Chat { resub(`${username}#${userstate.userId}, streak share: ${subStreakShareEnabled}, streak: ${subStreak}, months: ${amount}, message: ${message}, tier: ${tier}`); eventEmitter.emit('resub', { userName: username, - tier: String(tier), + tier, subStreakShareEnabled, subStreak, subStreakName: getLocalizedName(subStreak, translate('core.months')), @@ -517,6 +517,7 @@ class Chat { try { const userId = subInfo.gifterUserId ?? ''; const count = subInfo.count; + const tier = String(Number(subInfo.plan) / 1000) as EmitData['tier']; changelog.increment(userId, { giftedSubscribes: Number(count) }); @@ -533,14 +534,14 @@ class Chat { count, timestamp: Date.now(), }); - eventEmitter.emit('subcommunitygift', { userName: username, count }); + eventEmitter.emit('subcommunitygift', { userName: username, count, tier }); subcommunitygift(`${username}#${userId}, to ${count} viewers`); alerts.trigger({ eventId: eventData?.id ?? null, event: 'subcommunitygift', name: username, amount: Number(count), - tier: null, + tier, currency: '', monthsName: '', message: '', @@ -559,7 +560,7 @@ class Chat { const userId = subInfo.gifterUserId ?? '0'; const amount = subInfo.months; const recipientId = subInfo.userId; - const tier = (subInfo.isPrime ? 1 : (Number(subInfo.plan ?? 1000) / 1000)); + const tier = String(subInfo.isPrime ? 'Prime' : (Number(subInfo.plan ?? 1000) / 1000)) as EmitData['tier']; const ignoreGifts = (ignoreGiftsFromUser.get(userId) ?? 0); let isGiftIgnored = false;