@sdeck/twitch 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/model.ts ADDED
@@ -0,0 +1,195 @@
1
+ /** What the API says about the channel, in the form the plugin uses. */
2
+
3
+ type Raw = Record<string, unknown> | undefined;
4
+
5
+ const text = (value: unknown) => (typeof value === "string" ? value : "");
6
+ const count = (value: unknown) => (typeof value === "number" && Number.isFinite(value) ? value : 0);
7
+
8
+ export interface Stream {
9
+ live: boolean;
10
+ viewers: number;
11
+ /** When it went live (ms since 1970), or 0. */
12
+ startedAt: number;
13
+ }
14
+
15
+ /** Reads the first item of `GET /streams`, which lists only live streams. */
16
+ export function parseStream(raw: Raw): Stream {
17
+ const startedAt = Date.parse(text(raw?.started_at)) || 0;
18
+ return { live: raw !== undefined, viewers: count(raw?.viewer_count), startedAt };
19
+ }
20
+
21
+ export interface Channel {
22
+ title: string;
23
+ category: string;
24
+ categoryId: string;
25
+ }
26
+
27
+ export function parseChannel(raw: Raw): Channel {
28
+ return {
29
+ title: text(raw?.title),
30
+ category: text(raw?.game_name),
31
+ categoryId: text(raw?.game_id),
32
+ };
33
+ }
34
+
35
+ export const CHAT_MODES = {
36
+ emote_mode: "Emotes only",
37
+ subscriber_mode: "Subscribers only",
38
+ follower_mode: "Followers only",
39
+ slow_mode: "Slow mode",
40
+ unique_chat_mode: "No repeated messages",
41
+ } as const;
42
+ export type ChatMode = keyof typeof CHAT_MODES;
43
+
44
+ export type ChatSettings = Record<ChatMode, boolean> & {
45
+ slowSeconds: number;
46
+ followMinutes: number;
47
+ };
48
+
49
+ export function parseChat(raw: Raw): ChatSettings {
50
+ return {
51
+ emote_mode: raw?.emote_mode === true,
52
+ subscriber_mode: raw?.subscriber_mode === true,
53
+ follower_mode: raw?.follower_mode === true,
54
+ slow_mode: raw?.slow_mode === true,
55
+ unique_chat_mode: raw?.unique_chat_mode === true,
56
+ slowSeconds: count(raw?.slow_mode_wait_time) || 30,
57
+ followMinutes: count(raw?.follower_mode_duration),
58
+ };
59
+ }
60
+
61
+ /** The body that turns a chat mode on or off. Twitch refuses a time for a mode that is off. */
62
+ export function chatModeBody(
63
+ mode: ChatMode,
64
+ on: boolean,
65
+ times: { slowSeconds: number; followMinutes: number },
66
+ ): Record<string, unknown> {
67
+ return {
68
+ [mode]: on,
69
+ ...(on && mode === "slow_mode" && { slow_mode_wait_time: times.slowSeconds }),
70
+ ...(on && mode === "follower_mode" && { follower_mode_duration: times.followMinutes }),
71
+ };
72
+ }
73
+
74
+ export interface Ads {
75
+ /** When the next one starts (ms since 1970), or 0. */
76
+ nextAt: number;
77
+ snoozes: number;
78
+ }
79
+
80
+ /** A time as Twitch gives it: seconds since 1970, or a date. Empty and 0 mean none. */
81
+ export function parseTime(value: unknown): number {
82
+ if (typeof value === "number") return value * 1000;
83
+ if (typeof value !== "string" || value === "") return 0;
84
+ return /^\d+$/.test(value) ? Number(value) * 1000 : Date.parse(value) || 0;
85
+ }
86
+
87
+ export const parseAds = (raw: Raw): Ads => ({
88
+ nextAt: parseTime(raw?.next_ad_at),
89
+ snoozes: count(raw?.snooze_count),
90
+ });
91
+
92
+ /** `3725` → `1:02:05`, `65` → `1:05`. */
93
+ export function formatDuration(seconds: number): string {
94
+ const s = Math.max(0, Math.floor(seconds));
95
+ const two = (n: number) => String(n).padStart(2, "0");
96
+ const hours = Math.floor(s / 3600);
97
+ const minutes = Math.floor((s % 3600) / 60);
98
+ return hours > 0 ? `${hours}:${two(minutes)}:${two(s % 60)}` : `${minutes}:${two(s % 60)}`;
99
+ }
100
+
101
+ /** `https://twitch.tv/Name`, `@Name` or `Name` → `name`; `undefined` if it is none of them. */
102
+ export function channelLogin(input: string): string | undefined {
103
+ const name = input
104
+ .trim()
105
+ .replace(/^(?:https?:\/\/)?(?:www\.|m\.)?twitch\.tv\//i, "")
106
+ .replace(/^@/, "")
107
+ .replace(/[/?#].*$/, "");
108
+ return /^\w{2,25}$/.test(name) ? name.toLowerCase() : undefined;
109
+ }
110
+
111
+ // -- Events -------------------------------------------------------------------------------------
112
+
113
+ export type Role = "everyone" | "subscriber" | "vip" | "moderator" | "broadcaster";
114
+ const RANKS: readonly string[] = ["everyone", "subscriber", "vip", "moderator", "broadcaster"];
115
+
116
+ /** Whether someone with these badges is at least `role`. */
117
+ export function hasRole(badges: readonly string[], role: Role): boolean {
118
+ const ranks = badges.map((badge) => RANKS.indexOf(badge === "founder" ? "subscriber" : badge));
119
+ return Math.max(0, ...ranks) >= RANKS.indexOf(role);
120
+ }
121
+
122
+ /** What follows `command` in a chat message, or `undefined` if the message is not that command. */
123
+ export function commandWords(message: string, command: string): string | undefined {
124
+ const wanted = command.trim().toLowerCase();
125
+ const said = message.trim();
126
+ if (!wanted || !said.toLowerCase().startsWith(wanted)) return undefined;
127
+ const rest = said.slice(wanted.length);
128
+ return rest === "" || /^\s/.test(rest) ? rest.trim() : undefined;
129
+ }
130
+
131
+ type Data = Record<string, unknown>;
132
+
133
+ /** A subscription's tier, 1 to 3. */
134
+ const tier = (value: unknown) => Math.max(1, Math.round(Number(value) / 1000) || 1);
135
+
136
+ /** Who did it. There is no name when they chose to stay anonymous. */
137
+ const person = (data: Data) => ({
138
+ user: text(data.user_name) || "Anonymous",
139
+ login: text(data.user_login),
140
+ });
141
+
142
+ /** What the triggers give as `event`, by Twitch's event type. */
143
+ export const EVENTS = {
144
+ "stream.online": () => ({}),
145
+ "stream.offline": () => ({}),
146
+ "channel.follow": person,
147
+ "channel.subscribe": (d: Data) => ({
148
+ ...person(d),
149
+ tier: tier(d.tier),
150
+ gift: d.is_gift === true,
151
+ months: 1,
152
+ message: "",
153
+ }),
154
+ "channel.subscription.message": (d: Data) => ({
155
+ ...person(d),
156
+ tier: tier(d.tier),
157
+ gift: false,
158
+ months: count(d.cumulative_months),
159
+ message: text((d.message as Raw)?.text),
160
+ }),
161
+ "channel.subscription.gift": (d: Data) => ({
162
+ ...person(d),
163
+ tier: tier(d.tier),
164
+ total: count(d.total),
165
+ }),
166
+ "channel.cheer": (d: Data) => ({
167
+ ...person(d),
168
+ bits: count(d.bits),
169
+ message: text(d.message),
170
+ }),
171
+ "channel.raid": (d: Data) => ({
172
+ user: text(d.from_broadcaster_user_name),
173
+ login: text(d.from_broadcaster_user_login),
174
+ viewers: count(d.viewers),
175
+ }),
176
+ "channel.channel_points_custom_reward_redemption.add": (d: Data) => ({
177
+ ...person(d),
178
+ reward: text((d.reward as Raw)?.title),
179
+ cost: count((d.reward as Raw)?.cost),
180
+ input: text(d.user_input),
181
+ }),
182
+ "channel.ad_break.begin": (d: Data) => ({
183
+ seconds: count(Number(d.duration_seconds)),
184
+ automatic: String(d.is_automatic) === "true",
185
+ }),
186
+ "channel.chat.message": (d: Data) => ({
187
+ user: text(d.chatter_user_name),
188
+ login: text(d.chatter_user_login),
189
+ message: text((d.message as Raw)?.text),
190
+ badges: (Array.isArray(d.badges) ? d.badges : []).map((badge) => text(badge?.set_id)),
191
+ }),
192
+ } as const;
193
+
194
+ export type EventType = keyof typeof EVENTS;
195
+ export type EventData<T extends EventType> = ReturnType<(typeof EVENTS)[T]>;
package/src/plugin.ts ADDED
@@ -0,0 +1,193 @@
1
+ /** The plugin's connection to Twitch, and the channel's values while something uses them. */
2
+ import { createPlugin, ManagedConnection, Permissions, Shared, setting } from "@sdeck/plugin";
3
+ import { z } from "zod";
4
+ import { type Method, SignedOut, type SignIn, TwitchClient, type User } from "./api.ts";
5
+ import { type ChannelEvent, connectEvents } from "./events.ts";
6
+ import { parseAds, parseChannel, parseChat, parseStream } from "./model.ts";
7
+
8
+ export const plugin = createPlugin({
9
+ id: "@sdeck/twitch",
10
+ name: "Twitch",
11
+ version: "1.0.0",
12
+ description:
13
+ "Run your Twitch channel: chat modes, clips, markers, ads, raids and more, with live values and triggers.",
14
+ permissions: [Permissions.network],
15
+ settings: {
16
+ clientId: setting.text("Client ID", {
17
+ description: "Of your own app in the Twitch developer console, with client type Public.",
18
+ required: true,
19
+ validate: z
20
+ .string()
21
+ .trim()
22
+ .regex(/^[a-z0-9]{20,40}$/, "should be about 30 small letters and digits"),
23
+ }),
24
+ },
25
+ });
26
+
27
+ const TOKEN = "refreshToken";
28
+
29
+ export const twitch = new TwitchClient({
30
+ clientId: () => plugin.context?.settings().clientId.trim() ?? "",
31
+ tokens: {
32
+ get: () => plugin.context?.secrets.get(TOKEN),
33
+ set: async (token) => {
34
+ await plugin.context?.secrets.set(TOKEN, token);
35
+ },
36
+ },
37
+ });
38
+
39
+ // -- The channel's values -----------------------------------------------------------------------
40
+
41
+ const refreshers = new Set<() => void>();
42
+
43
+ /** Something read again and again while it is used, and at once after `refresh`. */
44
+ function polled<T>(everyMs: number, readNow: (user: User) => Promise<T>) {
45
+ let again: () => void = () => {};
46
+ const shared = new Shared<T | undefined>((emit) => {
47
+ let stopped = false;
48
+ let timer: ReturnType<typeof setTimeout> | undefined;
49
+ /** The newest reading; an older one that answers later is not used. */
50
+ let latest = 0;
51
+ const tick = async () => {
52
+ clearTimeout(timer);
53
+ const mine = ++latest;
54
+ try {
55
+ const value = await readNow(await twitch.user());
56
+ if (stopped || mine !== latest) return;
57
+ emit(value);
58
+ } catch (error) {
59
+ if (stopped || mine !== latest) return;
60
+ emit(undefined);
61
+ const { message } = error as Error;
62
+ plugin.context?.status(message, error instanceof SignedOut ? "info" : "error");
63
+ }
64
+ timer = setTimeout(tick, everyMs);
65
+ };
66
+ again = () => void tick();
67
+ const mine = again;
68
+ refreshers.add(mine);
69
+ mine();
70
+ return () => {
71
+ stopped = true;
72
+ clearTimeout(timer);
73
+ refreshers.delete(mine);
74
+ again = () => {};
75
+ };
76
+ });
77
+ return { shared, refresh: () => again() };
78
+ }
79
+
80
+ const own = (user: User) => ({ broadcaster_id: user.id });
81
+ /** The user moderates their own channel. */
82
+ const mod = (user: User) => ({ ...own(user), moderator_id: user.id });
83
+
84
+ export const readChannel = async (user: User) =>
85
+ parseChannel((await twitch.request("GET", "/channels", own(user)))[0]);
86
+ export const readChat = async (user: User) =>
87
+ parseChat((await twitch.request("GET", "/chat/settings", mod(user)))[0]);
88
+ export const readShield = async (user: User) =>
89
+ (await twitch.request("GET", "/moderation/shield_mode", mod(user)))[0]?.is_active === true;
90
+
91
+ export const stream = polled(20_000, async (user) =>
92
+ parseStream((await twitch.request("GET", "/streams", { user_id: user.id }))[0]),
93
+ );
94
+ export const channel = polled(60_000, readChannel);
95
+ export const chat = polled(20_000, readChat);
96
+ export const shield = polled(20_000, readShield);
97
+ export const ads = polled(30_000, async (user) =>
98
+ parseAds((await twitch.request("GET", "/channels/ads", own(user)))[0]),
99
+ );
100
+ export const followers = polled(60_000, async (user) => {
101
+ const { total } = await twitch.call("GET", "/channels/followers", { ...own(user), first: "1" });
102
+ return Number(total) || 0;
103
+ });
104
+
105
+ /** A change to the user's channel, as its moderator. */
106
+ export async function change(method: Method, path: string, body?: unknown) {
107
+ return twitch.request(method, path, mod(await twitch.user()), body);
108
+ }
109
+
110
+ // -- Events -------------------------------------------------------------------------------------
111
+
112
+ const listeners = new Set<(event: ChannelEvent) => void>();
113
+
114
+ const events = new ManagedConnection<User>({
115
+ open: (lost, signal) =>
116
+ connectEvents(
117
+ twitch,
118
+ (event) => {
119
+ if (event.type.startsWith("stream.")) stream.refresh();
120
+ if (event.type === "channel.follow") followers.refresh();
121
+ for (const listener of [...listeners]) listener(event);
122
+ },
123
+ lost,
124
+ signal,
125
+ (...args) => plugin.context?.log(...args),
126
+ ),
127
+ onStatus: (state, error) => {
128
+ if (state === "connected") plugin.context?.status("Signed in to Twitch", "ok");
129
+ else if (error) plugin.context?.status(error.message, twitch.signedIn ? "error" : "info");
130
+ },
131
+ });
132
+
133
+ /** Hears what happens on the channel, connecting if need be. */
134
+ export function onEvent(listener: (event: ChannelEvent) => void): () => void {
135
+ listeners.add(listener);
136
+ const release = events.hold();
137
+ return () => {
138
+ listeners.delete(listener);
139
+ release();
140
+ };
141
+ }
142
+
143
+ // -- Signing in ---------------------------------------------------------------------------------
144
+
145
+ let signingIn: SignIn | undefined;
146
+
147
+ /** Reads everything again: someone else may be signed in. */
148
+ function startOver() {
149
+ events.restart();
150
+ for (const refresh of [...refreshers]) refresh();
151
+ }
152
+
153
+ export const signIn = plugin.command({
154
+ id: "sign-in",
155
+ name: "Sign in",
156
+ description: "Opens Twitch in your browser to allow access.",
157
+ run: async (context) => {
158
+ signingIn?.cancel();
159
+ const started = await twitch.signIn();
160
+ signingIn = started;
161
+ context.status(`Allow access in the browser (code ${started.code})`, "info");
162
+ started.done.then(
163
+ () => {
164
+ context.status("Signed in to Twitch", "ok");
165
+ startOver();
166
+ },
167
+ (error: Error) => {
168
+ if (signingIn === started) context.status(error.message, "error");
169
+ },
170
+ );
171
+ return started.url;
172
+ },
173
+ });
174
+
175
+ export const signOut = plugin.command({
176
+ id: "sign-out",
177
+ name: "Sign out",
178
+ run: async (context) => {
179
+ signingIn?.cancel();
180
+ signingIn = undefined;
181
+ await twitch.signOut();
182
+ startOver();
183
+ context.status("Signed out", "info");
184
+ },
185
+ });
186
+
187
+ export const isSignedIn = () => twitch.signedIn;
188
+
189
+ export function stopAll() {
190
+ signingIn?.cancel();
191
+ signingIn = undefined;
192
+ events.close();
193
+ }
package/src/state.ts ADDED
@@ -0,0 +1,75 @@
1
+ /** The channel's live values: `{{twitch.viewers}}` and so on. */
2
+ import { following, type Shared } from "@sdeck/plugin";
3
+ import { type ChatMode, formatDuration } from "./model.ts";
4
+ import { ads, channel, chat, followers, plugin, shield, stream } from "./plugin.ts";
5
+
6
+ /** Follows a value that also changes as time passes, every second. */
7
+ const ticking =
8
+ <T, V>(shared: Shared<T | undefined>, pick: (value: T) => V) =>
9
+ (set: (value: V | undefined) => void) => {
10
+ const update = () => set(shared.last === undefined ? undefined : pick(shared.last));
11
+ const stop = shared.listen(update);
12
+ update();
13
+ const timer = setInterval(update, 1000);
14
+ return () => {
15
+ stop();
16
+ clearInterval(timer);
17
+ };
18
+ };
19
+
20
+ const { boolean, number, string } = plugin.state;
21
+ const chatMode = (id: string, name: string, mode: ChatMode) =>
22
+ boolean(id, name, { start: following(chat.shared, (c) => c[mode]) });
23
+
24
+ export const live = boolean("live", "Live", { start: following(stream.shared, (s) => s.live) });
25
+ export const viewers = number("viewers", "Viewers", {
26
+ start: following(stream.shared, (s) => s.viewers),
27
+ });
28
+ export const uptime = string("uptime", "Time live", {
29
+ description: "Such as 1:02:05; empty while offline.",
30
+ start: ticking(stream.shared, (s) =>
31
+ s.live ? formatDuration((Date.now() - s.startedAt) / 1000) : "",
32
+ ),
33
+ });
34
+ export const title = string("title", "Stream title", {
35
+ start: following(channel.shared, (c) => c.title),
36
+ });
37
+ export const category = string("category", "Category", {
38
+ start: following(channel.shared, (c) => c.category),
39
+ });
40
+ export const followerCount = number("followers", "Followers", {
41
+ start: following(followers.shared, (n) => n),
42
+ });
43
+ export const nextAd = string("nextAd", "Time to the next ad", {
44
+ description: "Such as 4:30; empty when none is planned.",
45
+ start: ticking(ads.shared, (a) =>
46
+ a.nextAt > Date.now() ? formatDuration((a.nextAt - Date.now()) / 1000) : "",
47
+ ),
48
+ });
49
+ export const snoozes = number("snoozes", "Ad snoozes left", {
50
+ start: following(ads.shared, (a) => a.snoozes),
51
+ });
52
+ export const shieldOn = boolean("shield", "Shield Mode", {
53
+ start: following(shield.shared, (on) => on),
54
+ });
55
+
56
+ export const chatModes = {
57
+ emote_mode: chatMode("emoteOnly", "Chat: emotes only", "emote_mode"),
58
+ subscriber_mode: chatMode("subscribersOnly", "Chat: subscribers only", "subscriber_mode"),
59
+ follower_mode: chatMode("followersOnly", "Chat: followers only", "follower_mode"),
60
+ slow_mode: chatMode("slowMode", "Chat: slow mode", "slow_mode"),
61
+ unique_chat_mode: chatMode("uniqueChat", "Chat: no repeated messages", "unique_chat_mode"),
62
+ };
63
+
64
+ export const state = [
65
+ live,
66
+ viewers,
67
+ uptime,
68
+ title,
69
+ category,
70
+ followerCount,
71
+ nextAd,
72
+ snoozes,
73
+ shieldOn,
74
+ ...Object.values(chatModes),
75
+ ];
@@ -0,0 +1,140 @@
1
+ import { setting } from "@sdeck/plugin";
2
+ import { rewards } from "./actions.ts";
3
+ import { commandWords, EVENTS, type EventData, type EventType, hasRole } from "./model.ts";
4
+ import { onEvent, plugin } from "./plugin.ts";
5
+
6
+ /** Calls `then` with every event of one type. */
7
+ const on = <T extends EventType>(type: T, then: (event: EventData<T>) => void) =>
8
+ onEvent((event) => {
9
+ if (event.type === type) then(EVENTS[type](event.data) as EventData<T>);
10
+ });
11
+
12
+ const online = plugin.trigger({
13
+ id: "online",
14
+ name: "When you go live",
15
+ subscribe: ({ fire }) => on("stream.online", fire),
16
+ });
17
+
18
+ const offline = plugin.trigger({
19
+ id: "offline",
20
+ name: "When your stream ends",
21
+ subscribe: ({ fire }) => on("stream.offline", fire),
22
+ });
23
+
24
+ const follow = plugin.trigger({
25
+ id: "follow",
26
+ name: "When someone follows",
27
+ description: "Gives event.user and event.login.",
28
+ subscribe: ({ fire }) => on("channel.follow", fire),
29
+ });
30
+
31
+ const subscribe = plugin.trigger({
32
+ id: "subscribe",
33
+ name: "When someone subscribes",
34
+ description: "Gives event.user, tier (1 to 3), months, message and gift.",
35
+ settings: { gifts: setting.boolean("Also for each gifted one", { default: true }) },
36
+ subscribe: ({ settings, fire }) => {
37
+ const stops = [
38
+ on("channel.subscribe", (event) => {
39
+ if (settings.gifts || !event.gift) fire(event);
40
+ }),
41
+ on("channel.subscription.message", fire),
42
+ ];
43
+ return () => {
44
+ for (const stop of stops) stop();
45
+ };
46
+ },
47
+ });
48
+
49
+ const gift = plugin.trigger({
50
+ id: "gift",
51
+ name: "When someone gives subscriptions",
52
+ description: "Gives event.user, total and tier.",
53
+ settings: { min: setting.number("At least this many", { default: 1, min: 1 }) },
54
+ subscribe: ({ settings, fire }) =>
55
+ on("channel.subscription.gift", (event) => {
56
+ if (event.total >= settings.min) fire(event);
57
+ }),
58
+ });
59
+
60
+ const cheer = plugin.trigger({
61
+ id: "cheer",
62
+ name: "When someone cheers",
63
+ description: "Gives event.user, bits and message.",
64
+ settings: { min: setting.number("At least this many bits", { default: 1, min: 1 }) },
65
+ subscribe: ({ settings, fire }) =>
66
+ on("channel.cheer", (event) => {
67
+ if (event.bits >= settings.min) fire(event);
68
+ }),
69
+ });
70
+
71
+ const raided = plugin.trigger({
72
+ id: "raid",
73
+ name: "When someone raids you",
74
+ description: "Gives event.user, login and viewers.",
75
+ settings: { min: setting.number("At least this many viewers", { default: 1, min: 1 }) },
76
+ subscribe: ({ settings, fire }) =>
77
+ on("channel.raid", (event) => {
78
+ if (event.viewers >= settings.min) fire(event);
79
+ }),
80
+ });
81
+
82
+ const redeem = plugin.trigger({
83
+ id: "redeem",
84
+ name: "When a reward is redeemed",
85
+ description: "Channel points. Gives event.user, reward, cost and input.",
86
+ settings: {
87
+ reward: setting.text("Reward", { source: rewards.id, placeholder: "Any reward" }),
88
+ },
89
+ subscribe: ({ settings, fire }) => {
90
+ const wanted = settings.reward.trim().toLowerCase();
91
+ return on("channel.channel_points_custom_reward_redemption.add", (event) => {
92
+ if (!wanted || event.reward.toLowerCase() === wanted) fire(event);
93
+ });
94
+ },
95
+ });
96
+
97
+ const adBreak = plugin.trigger({
98
+ id: "ad",
99
+ name: "When an ad starts",
100
+ description: "Gives event.seconds and automatic.",
101
+ subscribe: ({ fire }) => on("channel.ad_break.begin", fire),
102
+ });
103
+
104
+ const command = plugin.trigger({
105
+ id: "command",
106
+ name: "When someone writes a chat command",
107
+ description: "Gives event.user, message, and text: what follows the command.",
108
+ settings: {
109
+ command: setting.text("Command", { default: "!deck", required: true }),
110
+ who: setting.select(
111
+ "Who can use it",
112
+ {
113
+ everyone: "Everyone",
114
+ subscriber: "Subscribers and above",
115
+ vip: "VIPs and above",
116
+ moderator: "Moderators and you",
117
+ broadcaster: "Only you",
118
+ },
119
+ { default: "moderator" },
120
+ ),
121
+ },
122
+ subscribe: ({ settings, fire }) =>
123
+ on("channel.chat.message", (event) => {
124
+ const text = commandWords(event.message, settings.command);
125
+ if (text !== undefined && hasRole(event.badges, settings.who)) fire({ ...event, text });
126
+ }),
127
+ });
128
+
129
+ export const triggers = [
130
+ online,
131
+ offline,
132
+ follow,
133
+ subscribe,
134
+ gift,
135
+ cheer,
136
+ raided,
137
+ redeem,
138
+ adBreak,
139
+ command,
140
+ ];