@tixyel/streamelements 6.5.0 → 7.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/dist/index.d.ts CHANGED
@@ -7,220 +7,297 @@
7
7
  import { ComfyJSInstance, OnErrorHandler, OnCommandHandler, OnChatHandler, OnWhisperHandler, OnMessageDeletedHandler, OnJoinHandler, OnPartHandler, OnHostedHandler, OnRaidHandler, OnSubHandler, OnResubHandler, OnSubGiftHandler, OnSubMysteryGiftHandler, OnGiftSubContinueHandler, OnCheerHandler, OnChatModeHandler, OnRewardHandler, OnConnectedHandler, OnReconnectHandler } from 'comfy.js';
8
8
  export { ComfyJSInstance } from 'comfy.js';
9
9
 
10
- declare namespace YoutubeEvents {
11
- namespace Message {
12
- export type Data = {
13
- listener: 'message';
14
- event: Event;
15
- };
16
- export type Event = {
17
- service: 'youtube';
18
- data: {
19
- kind: string;
20
- etag: string;
21
- id: string;
22
- snippet: {
23
- type: string;
24
- liveChatId: string;
25
- authorChannelId: string;
26
- publishedAt: string;
27
- hasDisplayContent: boolean;
28
- displayMessage: string;
29
- textMessageDetails: {
30
- messageText: string;
31
- };
32
- };
33
- authorDetails: {
34
- channelId: string;
35
- channelUrl: string;
36
- displayName: string;
37
- profileImageUrl: string;
38
- isVerified: boolean;
39
- isChatOwner: boolean;
40
- isChatSponsor: boolean;
41
- isChatModerator: boolean;
42
- };
43
- msgId: string;
44
- userId: string;
45
- nick: string;
46
- badges: Array<Badges>;
47
- displayName: string;
48
- isAction: boolean;
49
- time: number;
50
- tags: Array<Tags>;
51
- displayColor: string | null;
52
- channel: string;
53
- text: string;
54
- avatar: string;
55
- emotes: Array<Emotes>;
56
- };
57
- renderedText: string;
58
- };
59
- type Badges = {};
60
- type Tags = {};
61
- type Emotes = {};
62
- export {};
63
- }
64
- namespace Superchat {
10
+ type Provider$1 = 'twitch' | 'youtube' | 'kick' | 'facebook' | 'streamelements';
11
+ type ClientEvents$1 = {
12
+ provider: 'streamelements';
13
+ data: StreamElements.Event.Provider.StreamElements.Events;
14
+ } | {
15
+ provider: 'twitch';
16
+ data: StreamElements.Event.Provider.Twitch.Events;
17
+ } | {
18
+ provider: 'youtube';
19
+ data: StreamElements.Event.Provider.YouTube.Events;
20
+ } | {
21
+ provider: 'kick';
22
+ data: StreamElements.Event.Provider.Kick.Events;
23
+ } | {
24
+ provider: 'facebook';
25
+ data: StreamElements.Event.Provider.Facebook.Events;
26
+ };
27
+
28
+ declare namespace StreamElementsEvents {
29
+ namespace Tip {
65
30
  type Data = {
66
- listener: 'superchat-latest';
31
+ listener: 'tip-latest';
67
32
  event: Event;
68
33
  };
69
34
  type Event = {
70
35
  amount: number;
71
36
  avatar: string;
37
+ name: string;
72
38
  displayName: string;
73
39
  providerId: string;
74
- name: string;
75
40
  _id: string;
76
41
  sessionTop: boolean;
77
- type: 'superchat';
78
- originalEventName: 'superchat-latest';
42
+ type: 'tip';
43
+ originalEventName: 'tip-latest';
79
44
  };
80
45
  }
81
- namespace Subscriber {
46
+ namespace KVStore {
82
47
  type Data = {
83
- listener: 'subscriber-latest';
48
+ listener: 'kvstore:update';
84
49
  event: Event;
85
50
  };
86
51
  type Event = {
87
- avatar: string;
88
- displayName: string;
89
- providerId: string;
90
- name: string;
91
- _id: string;
92
- sessionTop: boolean;
93
- type: 'subscriber';
94
- originalEventName: 'subscriber-latest';
52
+ data: {
53
+ key: `customWidget.${string}`;
54
+ value: string | number | boolean | Record<string, any>;
55
+ };
95
56
  };
96
57
  }
97
- namespace Sponsor {
58
+ namespace BotCounter {
98
59
  type Data = {
99
- listener: 'sponsor-latest';
60
+ listener: 'bot:counter';
100
61
  event: Event;
101
62
  };
102
- type Event = common & (normal | gift | community | spam);
103
- type common = {
104
- amount: number;
105
- name: string;
106
- displayName: string;
107
- message?: string;
108
- providerId?: string;
109
- avatar?: string;
110
- sender?: string;
111
- gifted?: boolean;
112
- bulkGifted?: boolean;
113
- isCommunityGift?: boolean;
114
- _id?: string;
115
- sessionTop?: boolean;
116
- playedAsCommunityGift?: boolean;
117
- type: 'sponsor';
118
- originalEventName: 'sponsor-latest';
119
- };
120
- type normal = {
121
- sender?: undefined;
122
- gifted?: false;
123
- bulkGifted?: false;
124
- isCommunityGift?: false;
125
- };
126
- type gift = {
127
- sender: string;
128
- gifted: true;
129
- bulkGifted?: false;
130
- isCommunityGift?: false;
63
+ type Event = {
64
+ counter: string;
65
+ value: number;
131
66
  };
132
- type community = {
133
- message: string;
134
- sender: string;
135
- gifted?: false;
136
- bulkGifted: true;
137
- isCommunityGift?: false;
67
+ }
68
+ namespace AlertService {
69
+ type Data = {
70
+ listener: 'alertService:toggleSound';
71
+ event: Event;
138
72
  };
139
- type spam = {
140
- sender: string;
141
- gifted: true;
142
- bulkGifted?: false;
143
- isCommunityGift: true;
73
+ type Event = {
74
+ muted: boolean;
144
75
  };
145
76
  }
146
- interface BaseEvent {
147
- provider: 'youtube';
148
- flagged: boolean;
149
- channel: string;
150
- createdAt: string;
151
- _id: string;
152
- expiresAt: string;
153
- updatedAt: string;
154
- activityId: string;
155
- sessionEventsCount: number;
156
- isMock?: boolean;
157
- }
158
- namespace Event {
77
+ namespace EventSkip {
159
78
  type Data = {
160
- listener: 'event';
79
+ listener: 'event:skip';
161
80
  event: Event;
162
81
  };
163
- type Event = Superchat | Subscriber | Sponsor | CommunityGiftedSponsor;
164
- interface Superchat extends BaseEvent {
165
- type: 'superchat';
166
- data: {
167
- amount: string;
168
- username: string;
169
- message: string;
170
- avatar: string;
171
- providerId: string;
172
- };
173
- }
174
- interface Subscriber extends BaseEvent {
175
- type: 'subscriber';
176
- data: {
177
- avatar: string;
178
- displayName: string;
179
- username: string;
180
- providerId: string;
181
- };
182
- }
183
- interface Sponsor extends BaseEvent {
184
- type: 'sponsor';
185
- data: FirstTimeSponsor | Resubscribe | GiftedSponsor;
186
- }
187
- type FirstTimeSponsor = {
188
- amount: number;
189
- username: string;
190
- displayName: string;
191
- providerId: string;
192
- avatar: string;
82
+ type Event = {};
83
+ }
84
+ namespace EventTest {
85
+ export type Data = {
86
+ listener: 'event:test';
87
+ event: Event;
193
88
  };
194
- type Resubscribe = {
195
- amount: number;
196
- username: string;
197
- displayName: string;
198
- providerId: string;
199
- avatar: string;
89
+ export type Event = widgetButton | emulatedEvents<EventType> | Session;
90
+ type items = {
91
+ name: string;
92
+ price: number;
93
+ quantity: number;
200
94
  };
201
- type GiftedSponsor = {
202
- amount: number;
203
- username: string;
204
- displayName: string;
205
- providerId: string;
206
- sender: string;
207
- gifted: true;
208
- avatar: string;
95
+ type widgetButton = {
96
+ listener: 'widget-button';
97
+ field: string;
98
+ value: string | number | boolean;
209
99
  };
210
- interface CommunityGiftedSponsor extends BaseEvent {
211
- type: 'communityGiftPurchase';
212
- data: {
100
+ type EventType = 'follower' | 'subscriber' | 'tip' | 'cheer' | 'raid';
101
+ type EventTier = 'prime' | '1000' | '2000' | '3000';
102
+ type emulatedEvents<T extends EventType> = {
103
+ listener: `${T}-latest`;
104
+ event: {
105
+ type: T;
106
+ name: string;
213
107
  amount: number;
214
- username: string;
215
- displayName: string;
216
- providerId: string;
217
- avatar: string;
108
+ count: number;
109
+ message?: string;
110
+ gifted?: boolean;
111
+ bulkGifted?: boolean;
112
+ sender?: string;
113
+ subExtension?: boolean;
114
+ items: items[];
115
+ tier: EventTier;
116
+ month: string;
117
+ isTest: true;
218
118
  };
219
- }
220
- }
221
- }
222
-
119
+ };
120
+ type Session = SessionCount | SessionTotal | SessionTop | SessionGoal | SessionRecent | SessionPoints;
121
+ type SessionCount = {
122
+ listener: `${EventType}-count`;
123
+ event: {
124
+ type: EventType;
125
+ name: string;
126
+ count: number;
127
+ items: items[];
128
+ tier: EventTier;
129
+ month: string;
130
+ isTest: true;
131
+ };
132
+ };
133
+ type SessionTotal = {
134
+ listener: `${EventType}-total`;
135
+ event: {
136
+ type: EventType;
137
+ name: string;
138
+ amount: number;
139
+ count: number;
140
+ items: items[];
141
+ tier: EventTier;
142
+ month: string;
143
+ isTest: true;
144
+ };
145
+ };
146
+ type SessionTop = {
147
+ listener: `${EventType}-top`;
148
+ event: {
149
+ type: EventType;
150
+ name: string;
151
+ amount: number;
152
+ count: number;
153
+ items: items[];
154
+ tier: EventTier;
155
+ month: string;
156
+ isTest: true;
157
+ };
158
+ };
159
+ type SessionGoal = {
160
+ listener: `${EventType}-goal`;
161
+ event: {
162
+ type: EventType;
163
+ name: string;
164
+ amount: number;
165
+ count: number;
166
+ items: items[];
167
+ tier: EventTier;
168
+ month: string;
169
+ isTest: true;
170
+ };
171
+ };
172
+ type SessionRecent = {
173
+ listener: `${EventType}-recent`;
174
+ event: {
175
+ event: SessionRecentEvent[];
176
+ };
177
+ };
178
+ type SessionRecentEvent = {
179
+ type: EventType;
180
+ name: string;
181
+ amount: number;
182
+ count: number;
183
+ tier: EventTier;
184
+ isTest: true;
185
+ };
186
+ type SessionPoints = {
187
+ listener: `${EventType}-points`;
188
+ event: {
189
+ type: EventType;
190
+ name: string;
191
+ amount: number;
192
+ count: number;
193
+ items: items[];
194
+ tier: EventTier;
195
+ month: string;
196
+ isTest: true;
197
+ };
198
+ };
199
+ export {};
200
+ }
201
+ interface BaseEvent {
202
+ provider: Provider$1;
203
+ flagged: boolean;
204
+ channel: string;
205
+ createdAt: string;
206
+ _id: string;
207
+ expiresAt: string;
208
+ updatedAt: string;
209
+ activityId: string;
210
+ sessionEventsCount: number;
211
+ isMock?: boolean;
212
+ }
213
+ namespace Event {
214
+ type Data = {
215
+ listener: 'event';
216
+ event: Event;
217
+ };
218
+ type Event = Tip;
219
+ interface Tip extends BaseEvent {
220
+ type: 'tip';
221
+ data: {
222
+ amount: string;
223
+ currency: string;
224
+ username: string;
225
+ message: string;
226
+ avatar: string;
227
+ };
228
+ }
229
+ }
230
+ }
231
+
232
+ type TwitchEmote = {
233
+ type: 'twitch';
234
+ name: string;
235
+ id: string;
236
+ gif: boolean;
237
+ urls: {
238
+ '1': string;
239
+ '2': string;
240
+ '4': string;
241
+ };
242
+ start: number;
243
+ end: number;
244
+ };
245
+ type FfzEmote = {
246
+ type: 'ffz';
247
+ id: string;
248
+ name: string;
249
+ gif: boolean;
250
+ animated: boolean;
251
+ urls: {
252
+ '1': string;
253
+ '2': string;
254
+ '4': string;
255
+ };
256
+ start: number;
257
+ end: number;
258
+ };
259
+ type SeventvEmote = {
260
+ type: '7tv';
261
+ name: string;
262
+ id: string;
263
+ gif: boolean;
264
+ animated: boolean;
265
+ urls: {
266
+ '1': string;
267
+ '2': string;
268
+ '3': string;
269
+ '4': string;
270
+ };
271
+ start: number;
272
+ end: number;
273
+ };
274
+ type BttvEmote = {
275
+ type: 'bttv';
276
+ name: string;
277
+ id: string;
278
+ gif: boolean;
279
+ animated: boolean;
280
+ urls: {
281
+ '1': string;
282
+ '2': string;
283
+ '4': string;
284
+ };
285
+ start: number;
286
+ end: number;
287
+ };
288
+ type Emoji = {
289
+ type: 'emoji';
290
+ name: string;
291
+ id: string;
292
+ gif: boolean;
293
+ urls: {
294
+ '1': string;
295
+ };
296
+ };
297
+ type Emote = TwitchEmote | BttvEmote | SeventvEmote | FfzEmote | Emoji;
298
+
223
299
  type PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? PathValue<T[K], Rest> : never : P extends keyof T ? T[P] : never;
300
+ type NumberAsString = string;
224
301
  type MapNumberValuesToString<T> = {
225
302
  [K in keyof T]: T[K] extends number ? `${T[K]}` | ReturnType<T[K]['toString']> : T[K];
226
303
  };
@@ -235,7 +312,7 @@ declare namespace Twitch {
235
312
  * 'subscriber/25'
236
313
  * ```
237
314
  */
238
- 'badge-info': String;
315
+ 'badge-info': string;
239
316
  /**
240
317
  * Comma-separated list of chat badges in the form, <badge>/<version>. For example admin/1. There are many possible badge values, but here are few: admin, bits, broadcaster, moderator, subscriber, staff, turbo
241
318
  * Most badges have only 1 version, but some badges like subscriber badges offer different versions of the badge depending on how long the user has subscribed.
@@ -244,7 +321,7 @@ declare namespace Twitch {
244
321
  * 'staff/1,bits/1000,partner/1'
245
322
  * ```
246
323
  */
247
- 'badges': String;
324
+ badges: string;
248
325
  /**
249
326
  * The color of the user's name in the chat.
250
327
  * @example
@@ -252,7 +329,7 @@ declare namespace Twitch {
252
329
  * '#FF0000'
253
330
  * ```
254
331
  */
255
- 'color': string | undefined;
332
+ color: string | undefined;
256
333
  /**
257
334
  * The user’s display name, escaped as described in the [IRCv3 spec](https://ircv3.net/specs/extensions/message-tags.html). This tag may be empty if it is never set.
258
335
  * @example
@@ -260,11 +337,11 @@ declare namespace Twitch {
260
337
  * 'TwitchUser'
261
338
  * ```
262
339
  */
263
- 'display-name': String;
340
+ 'display-name': string;
264
341
  /**
265
342
  * A comma-delimited list of IDs that identify the emote sets that the user has access to. Is always set to at least zero (0).
266
343
  */
267
- 'emote-sets': String;
344
+ 'emote-sets': string;
268
345
  /**
269
346
  * A slash-delimited list of emotes and their positions in the message. Each emote is in the form, `<emote ID>:<ranges>`, where ranges are comma-delimited pairs of indices in the form `<start position>-<end position>`. The position indices are zero-based.
270
347
  * NOTE: It’s possible for a message to begin with with `\001ACTION` when /me is used by a user in chat. In these cases emote positions should be considered to begin after `001ACTION `, which includes its succeeding whitespace.
@@ -273,12 +350,12 @@ declare namespace Twitch {
273
350
  * '25:0-4,12-16/1902:6-10'
274
351
  * ```
275
352
  */
276
- 'emotes': String;
277
- 'flags': String;
353
+ emotes: string;
354
+ flags: string;
278
355
  /**
279
356
  * A Boolean value that indicates whether the user has site-wide commercial free mode enabled. Is true (1) if enabled; otherwise, false (0).
280
357
  */
281
- 'turbo': 0 | 1;
358
+ turbo: 0 | 1;
282
359
  /**
283
360
  * The User ID of the relevant user.
284
361
  * @example
@@ -286,25 +363,26 @@ declare namespace Twitch {
286
363
  * '1337'
287
364
  * ```
288
365
  */
289
- 'user-id': String;
366
+ 'user-id': string;
290
367
  /**
291
368
  * The type of user. Possible values are:
292
369
  * ```
293
370
  * • "" - A normal user
371
+ * • mod - A channel moderator
294
372
  * • admin - A Twitch administrator
295
373
  * • global_mod - A global moderator
296
374
  * • staff - A Twitch employee
297
375
  * ```
298
376
  */
299
- 'user-type': '' | 'admin' | 'global_mod' | 'staff';
377
+ 'user-type': '' | 'mod' | 'admin' | 'global_mod' | 'staff';
300
378
  /**
301
379
  * The amount of Bits the user cheered. Only a Bits cheer message includes this tag.
302
380
  */
303
- 'bits': number;
381
+ bits: number;
304
382
  /**
305
383
  * A Boolean value that determines whether the user is a moderator. Is true (1) if the user is a moderator; otherwise, false (0).
306
384
  */
307
- 'mod': 0 | 1;
385
+ mod: 0 | 1;
308
386
  /**
309
387
  * The ID of the message. In UUID format.
310
388
  */
@@ -340,19 +418,19 @@ declare namespace Twitch {
340
418
  /**
341
419
  * An ID that identifies the chat room (channel).
342
420
  */
343
- 'room-id': String;
421
+ 'room-id': string;
344
422
  /**
345
423
  * Comma-separated list of chat badges for the chatter in the room the message was sent from. This uses the same format as the `badges` tag.
346
424
  */
347
- 'source-badges': String;
425
+ 'source-badges': string;
348
426
  /**
349
427
  * Contains metadata related to the chat badges in the source-badges tag.
350
428
  */
351
- 'source-badge-info': String;
429
+ 'source-badge-info': string;
352
430
  /**
353
431
  * A UUID that identifies the source message from the channel the message was sent from.
354
432
  */
355
- 'source-id': String;
433
+ 'source-id': string;
356
434
  /**
357
435
  * A Boolean that indicates if a message sent during a shared chat session is only sent to the source channel. Has no effect if the message is not sent during a shared chat session.
358
436
  */
@@ -360,11 +438,11 @@ declare namespace Twitch {
360
438
  /**
361
439
  * An ID that identifies the chat room (channel) the message was sent from.
362
440
  */
363
- 'source-room-id': String;
441
+ 'source-room-id': string;
364
442
  /**
365
443
  * A Boolean value that determines whether the user is a subscriber. Is true (1) if the user is a subscriber; otherwise, false (0).
366
444
  */
367
- 'subscriber': 0 | 1;
445
+ subscriber: 0 | 1;
368
446
  /**
369
447
  * The UNIX timestamp.
370
448
  */
@@ -372,7 +450,18 @@ declare namespace Twitch {
372
450
  /**
373
451
  * A Boolean value that determines whether the user that sent the chat is a VIP. The message includes this tag if the user is a VIP; otherwise, the message doesn’t include this tag (check for the presence of the tag instead of whether the tag is set to true or false).
374
452
  */
375
- 'vip': undefined | '';
453
+ vip: undefined | '';
454
+ };
455
+ type Reply = {
456
+ msgId: string;
457
+ userId: string;
458
+ userLogin: string;
459
+ displayName: string;
460
+ msgBody: string;
461
+ };
462
+ type Thread = {
463
+ parentMsgId: string;
464
+ parentUserLogin: string;
376
465
  };
377
466
  type badge = {
378
467
  type: string;
@@ -380,7 +469,20 @@ declare namespace Twitch {
380
469
  url: string;
381
470
  description: string;
382
471
  };
383
- type roles = '100 bits' | 'no audio' | 'no video' | 'bot' | 'twitch staff' | 'admins' | 'artist' | 'game developer' | 'prime' | 'turbo' | 'subscriber' | 'broadcaster' | 'verified' | 'moderator' | 'vip';
472
+ type GlobalBadge = {
473
+ set_id: tags;
474
+ versions: Array<{
475
+ id: string;
476
+ image_url_1x: string;
477
+ image_url_2x: string;
478
+ image_url_4x: string;
479
+ title: string;
480
+ description: string;
481
+ click_action: string | null;
482
+ click_url: string | null;
483
+ }>;
484
+ };
485
+ type tags = 'qsmp2' | 'jasontheween-7-day-survival' | 'support-a-streamer-ho26-badge' | 'twitch-recap-2025' | 'ugly-sweater' | 'fright-fest-2025' | 'gamerduo' | 'video-games-day' | 'twitch-intern-2022' | 'touch-grass' | 'twitchcon-referral-program-2025-chrome-star' | 'twitchcon-referral-program-2025-bleedpurple' | 'share-the-love' | 'gone-bananas' | 'twitchcon-2025---rotterdam' | 'clip-the-halls' | 'twitch-recap-2024' | 'subtember-2024' | 'twitch-intern-2024' | 'twitch-dj' | 'destiny-2-the-final-shape-streamer' | 'destiny-2-final-shape-raid-race' | 'twitchcon-2024---san-diego' | 'minecraft-15th-anniversary-celebration' | 'warcraft' | 'vip' | 'vga-champ-2017' | 'tyranny_1' | 'twitchconNA2023' | 'twitchconNA2020' | 'twitchconNA2022' | 'twitchconNA2019' | 'twitchconEU2023' | 'twitchconEU2022' | 'twitchcon2018' | 'twitchconAmsterdam2020' | 'twitchconEU2019' | 'twitchbot' | 'twitchcon2017' | 'twitchcon-2024---rotterdam' | 'twitch-recap-2023' | 'twitch-intern-2023' | 'treasure-adventure-world_1' | 'titan-souls_1' | 'this-war-of-mine_1' | 'the-surge_2' | 'the-surge_1' | 'the-surge_3' | 'the-golden-predictor-of-the-game-awards-2023' | 'the-game-awards-2023' | 'superhot_1' | 'strafe_1' | 'streamer-awards-2024' | 'starbound_1' | 'staff' | 'samusoffer_beta' | 'rplace-2023' | 'rift_1' | 'raiden-v-directors-cut_1' | 'psychonauts_1' | 'premium' | 'overwatch-league-insider_2019B' | 'partner' | 'overwatch-league-insider_2019A' | 'okhlos_1' | 'overwatch-league-insider_2018B' | 'overwatch-league-insider_1' | 'kingdom-new-lands_1' | 'jackbox-party-pack_1' | 'innerspace_2' | 'innerspace_1' | 'hype-train' | 'hello_neighbor_1' | 'gold-pixel-heart' | 'heavy-bullets_1' | 'glitchcon2020' | 'glhf-pledge' | 'getting-over-it_2' | 'getting-over-it_1' | 'frozen-synapse_1' | 'founder' | 'frozen-cortext_1' | 'firewatch_1' | 'enter-the-gungeon_1' | 'duelyst_5' | 'duelyst_6' | 'duelyst_7' | 'duelyst_2' | 'duelyst_4' | 'duelyst_3' | 'duelyst_1' | 'devilian_1' | 'devil-may-cry-hd_4' | 'devil-may-cry-hd_3' | 'devil-may-cry-hd_2' | 'devil-may-cry-hd_1' | 'deceit_1' | 'darkest-dungeon_1' | 'cuphead_1' | 'clip-champ' | 'broken-age_1' | 'bubsy-the-woolies_1' | 'bits-leader' | 'brawlhalla_1' | 'bits' | 'bits-charity' | 'battlechefbrigade_3' | 'battlerite_1' | 'battlechefbrigade_2' | 'battlechefbrigade_1' | 'axiom-verge_1' | 'anomaly-2_1' | 'anomaly-warzone-earth_1' | 'ambassador' | 'H1Z1_1' | '60-seconds_3' | '60-seconds_2' | '60-seconds_1' | '1979-revolution_1' | '10-years-as-twitch-staff' | '15-years-as-twitch-staff' | '5-years-as-twitch-staff' | 'aang' | 'admin' | 'alone' | 'anonymous-cheerer' | 'arc-raiders-launch-2025' | 'arcane-season-2-premiere' | 'artist-badge' | 'battlefield-6' | 'bingbonglove' | 'black-ops-7-global-launch' | 'borderlands-4-badge---ripper' | 'borderlands-4-badge---vault-symbol' | 'bot-badge' | 'broadcaster' | 'bungie-foundation-ally' | 'bungie-foundation-supporter' | 'chatter-cs-go-2022' | 'clips-leader' | 'creator-cs-go-2022' | 'crimson-butterfly' | 'diablo-30th-anniversary' | 'diana' | 'ditto' | 'dragonscimmy' | 'dreamcon-2024' | 'elden-ring-recluse' | 'elden-ring-wylder' | 'eso_1' | 'evo-2025' | 'extension' | 'fallout-season-2-ghoul' | 'first-stand-2026-supporter' | 'first-stand-2026-viewer' | 'fischer' | 'frog-lantern' | 'game-developer' | 'gears-of-war-superfan-badge' | 'gingko-leaf' | 'global_mod' | 'gold-pixel-heart---together-for-good-24' | 'gp-explorer-3' | 'hornet' | 'hunt-crosses' | 'hypershot-celestial' | 'jeff-the-land-shark' | 'k4sen-con-2025' | 'kodama' | 'la-velada-iv' | 'la-velada-v-badge' | 'lamby' | 'lead_moderator' | 'league-of-legends-mid-season-invitational-2025---grey' | 'league-of-legends-mid-season-invitational-2025---purple' | 'legendus' | 'lol-worlds-2025' | 'lost-ark-anniversary' | 'low' | 'marathon-reveal-runner' | 'marathon-silkworm' | 'marathon-sub-burger' | 'mel' | 'moderator' | 'moments' | 'mr-raccoon' | 'never-grave---witch-hat' | 'no_audio' | 'no_video' | 'path-of-exile-2-badge' | 'pokemon-30th-anniversary' | 'pokemon-legends-z-a-chikorita' | 'pokemon-legends-z-a-tepig' | 'pokemon-legends-z-a-totodile' | 'power-rangers' | 'predictions' | 'purple-noob' | 'purple-pixel-heart---together-for-good-24' | 'raging-wolf-helm' | 'raider-icon-badge' | 'rainbow-six-siege-x-10th-anniversary' | 'revedtv-stream-awards-2025' | 'ruby-pixel-heart---together-for-good-24' | 'rudy' | 'rustmas-2025' | 'sajam-slam-badge' | 'scampuss' | 'seeks-eye' | 'social-sharing' | 'sonic-racing-crossworlds' | 'speedons-5-badge' | 'stream-for-humanity-2-2025' | 'streamer-awards-tux' | 'sub-gift-leader' | 'sub-gifter' | 'subscriber' | 'subtember-2025' | 'superultracombo-2023' | 'survival-cup-4' | 'tft-paris-open' | 'the-deer' | 'the-first-descendant-badge' | 'the-man-without-fear' | 'the-onryos-mask' | 'together-for-good-25---good-badge' | 'together-for-good-25---gooder-badge' | 'together-for-good-25---goodest-badge' | 'together-for-good-25---wicked-dub-badge' | 'total-war-anniversary' | 'toxic-zombie' | 'turbo' | 'twitchcon-2026-europe-row-houses' | 'twitchcon-2026-europe-windmill' | 'umbrella-corporation' | 'user-anniversary' | 'vct-paris-2025' | 'yellow-noob' | 'zevent-2024' | 'zevent25';
384
486
  }
385
487
 
386
488
  declare namespace TwitchEvents {
@@ -394,11 +496,23 @@ declare namespace TwitchEvents {
394
496
  data: {
395
497
  time: number;
396
498
  tags: Partial<MapNumberValuesToString<Twitch.IRC>> & {
499
+ 'badge-info': string;
500
+ 'badges': string;
397
501
  'client-nonce': string;
502
+ 'color': string;
503
+ 'display-name': string;
504
+ 'emotes': string;
505
+ 'first-msg': '1' | '0';
398
506
  'flags': string;
399
507
  'id': string;
400
- 'first-msg': '1' | '0';
508
+ 'mod': '1' | '0';
401
509
  'returning-chatter': '1' | '0';
510
+ 'room-id': string;
511
+ 'subscriber': '1' | '0';
512
+ 'tmi-sent-ts': string;
513
+ 'turbo': '1' | '0';
514
+ 'user-id': string;
515
+ 'user-type': '' | 'mod' | 'admin' | 'global_mod' | 'staff';
402
516
  };
403
517
  nick: string;
404
518
  displayName: string;
@@ -419,19 +533,6 @@ declare namespace TwitchEvents {
419
533
  description: string;
420
534
  url: string;
421
535
  };
422
- type Emote = {
423
- type: string;
424
- name: string;
425
- id: string;
426
- gif: boolean;
427
- urls: {
428
- '1': string;
429
- '2': string;
430
- '4': string;
431
- };
432
- start: number;
433
- end: number;
434
- };
435
536
  export {};
436
537
  }
437
538
  namespace DeleteMessage {
@@ -659,65 +760,278 @@ declare namespace TwitchEvents {
659
760
  }
660
761
  }
661
762
 
662
- declare namespace StreamElements {
663
- namespace CustomField {
664
- type Types = 'button' | 'number' | 'slider' | 'text' | 'hidden' | 'checkbox' | 'dropdown' | 'colorpicker' | 'googleFont' | 'video-input' | 'image-input' | 'sound-input';
665
- type Schema = {
666
- type: Types;
667
- label: string;
668
- value?: string | number | boolean;
669
- group?: string;
670
- min?: number | string;
671
- max?: number | string;
672
- step?: number | string;
673
- options?: Record<string, string>;
674
- multiple?: boolean;
675
- };
676
- type Value = string | number | boolean | undefined;
677
- }
678
- type SE_API = {
679
- responses: Record<string, any>;
680
- sendMessage: (message: string, data: object) => void;
681
- counters: {
682
- get: (key: string) => number | null;
683
- };
684
- store: {
685
- get: <T>(key: string) => Promise<T | null>;
686
- set: <T>(key: string, value: T) => void;
687
- };
688
- resumeQueue: () => void;
689
- sanitize: (message: string) => string;
690
- cheerFilter: (message: string) => string;
691
- setField: (key: string, value: string | number | boolean | undefined, reload: boolean) => void;
692
- getOverlayStatus: () => {
693
- isEditorMode: boolean;
694
- muted: boolean;
763
+ declare namespace YoutubeEvents {
764
+ namespace Message {
765
+ export type Data = {
766
+ listener: 'message';
767
+ event: Event;
695
768
  };
696
- };
697
- namespace Event {
698
- type onWidgetLoad = {
699
- channel: {
700
- username: string;
701
- /**
702
- * The channel's streamelements api token (used to authenticate requests to the SE API)
703
- */
704
- apiToken: string;
705
- /**
706
- * The channel's unique identifier in the SE system
707
- */
769
+ export type Event = {
770
+ service: 'youtube';
771
+ data: {
772
+ kind: string;
773
+ etag: string;
708
774
  id: string;
709
- /**
710
- * The channel's unique identifier from the provider (e.g. Twitch user ID)
711
- */
712
- providerId: string;
713
- avatar: string;
714
- };
715
- currency: {
716
- code: string;
717
- name: string;
718
- symbol: string;
719
- };
720
- fieldData: Record<string, StreamElements.CustomField.Value>;
775
+ snippet: {
776
+ type: string;
777
+ liveChatId: string;
778
+ authorChannelId: string;
779
+ publishedAt: string;
780
+ hasDisplayContent: boolean;
781
+ displayMessage: string;
782
+ textMessageDetails: {
783
+ messageText: string;
784
+ };
785
+ };
786
+ authorDetails: {
787
+ channelId: string;
788
+ channelUrl: string;
789
+ displayName: string;
790
+ profileImageUrl: string;
791
+ isVerified: boolean;
792
+ isChatOwner: boolean;
793
+ isChatSponsor: boolean;
794
+ isChatModerator: boolean;
795
+ };
796
+ msgId: string;
797
+ userId: string;
798
+ nick: string;
799
+ badges: Array<Badges>;
800
+ displayName: string;
801
+ isAction: boolean;
802
+ time: number;
803
+ tags: Array<Tags>;
804
+ displayColor: string | null;
805
+ channel: string;
806
+ text: string;
807
+ avatar: string;
808
+ emotes: Array<Emotes>;
809
+ };
810
+ renderedText: string;
811
+ };
812
+ type Badges = {};
813
+ type Tags = {};
814
+ type Emotes = {};
815
+ export {};
816
+ }
817
+ namespace Superchat {
818
+ type Data = {
819
+ listener: 'superchat-latest';
820
+ event: Event;
821
+ };
822
+ type Event = {
823
+ amount: number;
824
+ avatar: string;
825
+ displayName: string;
826
+ providerId: string;
827
+ name: string;
828
+ _id: string;
829
+ sessionTop: boolean;
830
+ type: 'superchat';
831
+ originalEventName: 'superchat-latest';
832
+ };
833
+ }
834
+ namespace Subscriber {
835
+ type Data = {
836
+ listener: 'subscriber-latest';
837
+ event: Event;
838
+ };
839
+ type Event = {
840
+ avatar: string;
841
+ displayName: string;
842
+ providerId: string;
843
+ name: string;
844
+ _id: string;
845
+ sessionTop: boolean;
846
+ type: 'subscriber';
847
+ originalEventName: 'subscriber-latest';
848
+ };
849
+ }
850
+ namespace Sponsor {
851
+ type Data = {
852
+ listener: 'sponsor-latest';
853
+ event: Event;
854
+ };
855
+ type Event = common & (normal | gift | community | spam);
856
+ type common = {
857
+ amount: number;
858
+ name: string;
859
+ displayName: string;
860
+ message?: string;
861
+ providerId?: string;
862
+ avatar?: string;
863
+ sender?: string;
864
+ gifted?: boolean;
865
+ bulkGifted?: boolean;
866
+ isCommunityGift?: boolean;
867
+ _id?: string;
868
+ sessionTop?: boolean;
869
+ playedAsCommunityGift?: boolean;
870
+ type: 'sponsor';
871
+ originalEventName: 'sponsor-latest';
872
+ };
873
+ type normal = {
874
+ sender?: undefined;
875
+ gifted?: false;
876
+ bulkGifted?: false;
877
+ isCommunityGift?: false;
878
+ };
879
+ type gift = {
880
+ sender: string;
881
+ gifted: true;
882
+ bulkGifted?: false;
883
+ isCommunityGift?: false;
884
+ };
885
+ type community = {
886
+ message: string;
887
+ sender: string;
888
+ gifted?: false;
889
+ bulkGifted: true;
890
+ isCommunityGift?: false;
891
+ };
892
+ type spam = {
893
+ sender: string;
894
+ gifted: true;
895
+ bulkGifted?: false;
896
+ isCommunityGift: true;
897
+ };
898
+ }
899
+ interface BaseEvent {
900
+ provider: 'youtube';
901
+ flagged: boolean;
902
+ channel: string;
903
+ createdAt: string;
904
+ _id: string;
905
+ expiresAt: string;
906
+ updatedAt: string;
907
+ activityId: string;
908
+ sessionEventsCount: number;
909
+ isMock?: boolean;
910
+ }
911
+ namespace Event {
912
+ type Data = {
913
+ listener: 'event';
914
+ event: Event;
915
+ };
916
+ type Event = Superchat | Subscriber | Sponsor | CommunityGiftedSponsor;
917
+ interface Superchat extends BaseEvent {
918
+ type: 'superchat';
919
+ data: {
920
+ amount: string;
921
+ username: string;
922
+ message: string;
923
+ avatar: string;
924
+ providerId: string;
925
+ };
926
+ }
927
+ interface Subscriber extends BaseEvent {
928
+ type: 'subscriber';
929
+ data: {
930
+ avatar: string;
931
+ displayName: string;
932
+ username: string;
933
+ providerId: string;
934
+ };
935
+ }
936
+ interface Sponsor extends BaseEvent {
937
+ type: 'sponsor';
938
+ data: FirstTimeSponsor | Resubscribe | GiftedSponsor;
939
+ }
940
+ type FirstTimeSponsor = {
941
+ amount: number;
942
+ username: string;
943
+ displayName: string;
944
+ providerId: string;
945
+ avatar: string;
946
+ };
947
+ type Resubscribe = {
948
+ amount: number;
949
+ username: string;
950
+ displayName: string;
951
+ providerId: string;
952
+ avatar: string;
953
+ };
954
+ type GiftedSponsor = {
955
+ amount: number;
956
+ username: string;
957
+ displayName: string;
958
+ providerId: string;
959
+ sender: string;
960
+ gifted: true;
961
+ avatar: string;
962
+ };
963
+ interface CommunityGiftedSponsor extends BaseEvent {
964
+ type: 'communityGiftPurchase';
965
+ data: {
966
+ amount: number;
967
+ username: string;
968
+ displayName: string;
969
+ providerId: string;
970
+ avatar: string;
971
+ };
972
+ }
973
+ }
974
+ }
975
+
976
+ declare namespace StreamElements {
977
+ namespace CustomField {
978
+ type Types = 'button' | 'number' | 'slider' | 'text' | 'hidden' | 'checkbox' | 'dropdown' | 'colorpicker' | 'googleFont' | 'video-input' | 'image-input' | 'sound-input';
979
+ type Schema = {
980
+ type: Types;
981
+ label: string;
982
+ value?: string | number | boolean;
983
+ group?: string;
984
+ min?: number | string;
985
+ max?: number | string;
986
+ step?: number | string;
987
+ options?: Record<string, string>;
988
+ multiple?: boolean;
989
+ };
990
+ type Value = string | number | boolean | undefined;
991
+ }
992
+ type SE_API = {
993
+ responses: Record<string, any>;
994
+ sendMessage: (message: string, data: object) => void;
995
+ counters: {
996
+ get: (key: string) => number | null;
997
+ };
998
+ store: {
999
+ get: <T>(key: string) => Promise<T | null>;
1000
+ set: <T>(key: string, value: T) => void;
1001
+ };
1002
+ resumeQueue: () => void;
1003
+ sanitize: (message: string) => string;
1004
+ cheerFilter: (message: string) => string;
1005
+ setField: (key: string, value: string | number | boolean | undefined, reload: boolean) => void;
1006
+ getOverlayStatus: () => {
1007
+ isEditorMode: boolean;
1008
+ muted: boolean;
1009
+ };
1010
+ };
1011
+ namespace Event {
1012
+ type onWidgetLoad = {
1013
+ channel: {
1014
+ username: string;
1015
+ /**
1016
+ * The channel's streamelements api token (used to authenticate requests to the SE API)
1017
+ */
1018
+ apiToken: string;
1019
+ /**
1020
+ * The channel's unique identifier in the SE system
1021
+ */
1022
+ id: string;
1023
+ /**
1024
+ * The channel's unique identifier from the provider (e.g. Twitch user ID)
1025
+ */
1026
+ providerId: string;
1027
+ avatar: string;
1028
+ };
1029
+ currency: {
1030
+ code: string;
1031
+ name: string;
1032
+ symbol: string;
1033
+ };
1034
+ fieldData: Record<string, StreamElements.CustomField.Value>;
721
1035
  recents: Array<Object>;
722
1036
  session: {
723
1037
  data: StreamElements.Session.Data;
@@ -1277,1454 +1591,1524 @@ declare namespace StreamElements {
1277
1591
  name: string;
1278
1592
  amount: number;
1279
1593
  };
1280
- 'tip-session-top-donator': {
1281
- name: string;
1282
- amount: number;
1283
- };
1284
- 'tip-weekly-top-donator': {
1285
- name: string;
1286
- amount: number;
1287
- };
1288
- 'tip-monthly-top-donator': {
1289
- name: string;
1290
- amount: number;
1291
- };
1292
- 'tip-alltime-top-donator': {
1293
- name: string;
1294
- amount: number;
1295
- };
1296
- 'tip-session': {
1297
- amount: number;
1298
- };
1299
- 'tip-week': {
1300
- amount: number;
1301
- };
1302
- 'tip-month': {
1303
- amount: number;
1304
- };
1305
- 'tip-total': {
1306
- amount: number;
1307
- };
1308
- 'tip-count': {
1309
- count: number;
1310
- };
1311
- 'tip-goal': {
1312
- amount: number;
1313
- };
1314
- 'tip-recent': {
1315
- name: string;
1316
- amount: number;
1317
- createdAt: string;
1318
- }[];
1319
- }
1320
- interface Merch {
1321
- 'merch-latest': {
1322
- name: string;
1323
- amount: number;
1324
- items: any[];
1325
- };
1326
- 'merch-goal-orders': {
1327
- amount: number;
1328
- };
1329
- 'merch-goal-items': {
1330
- amount: number;
1331
- };
1332
- 'merch-goal-total': {
1333
- amount: number;
1334
- };
1335
- 'merch-recent': {
1336
- name: string;
1337
- }[];
1338
- }
1339
- interface Purchase {
1340
- 'purchase-latest': {
1341
- name: string;
1342
- amount: number;
1343
- items: any[];
1344
- avatar: string;
1345
- message: string;
1346
- };
1347
- }
1348
- }
1349
- }
1350
-
1351
- type Provider$1 = 'twitch' | 'youtube' | 'kick' | 'facebook' | 'streamelements';
1352
- type ClientEvents$1 = {
1353
- provider: 'streamelements';
1354
- data: StreamElements.Event.Provider.StreamElements.Events;
1355
- } | {
1356
- provider: 'twitch';
1357
- data: StreamElements.Event.Provider.Twitch.Events;
1358
- } | {
1359
- provider: 'youtube';
1360
- data: StreamElements.Event.Provider.YouTube.Events;
1361
- } | {
1362
- provider: 'kick';
1363
- data: StreamElements.Event.Provider.Kick.Events;
1364
- } | {
1365
- provider: 'facebook';
1366
- data: StreamElements.Event.Provider.Facebook.Events;
1367
- };
1368
-
1369
- declare namespace StreamElementsEvents {
1370
- namespace Tip {
1371
- type Data = {
1372
- listener: 'tip-latest';
1373
- event: Event;
1374
- };
1375
- type Event = {
1376
- amount: number;
1377
- avatar: string;
1378
- name: string;
1379
- displayName: string;
1380
- providerId: string;
1381
- _id: string;
1382
- sessionTop: boolean;
1383
- type: 'tip';
1384
- originalEventName: 'tip-latest';
1385
- };
1386
- }
1387
- namespace KVStore {
1388
- type Data = {
1389
- listener: 'kvstore:update';
1390
- event: Event;
1391
- };
1392
- type Event = {
1393
- data: {
1394
- key: `customWidget.${string}`;
1395
- value: string | number | boolean | Record<string, any>;
1396
- };
1397
- };
1398
- }
1399
- namespace BotCounter {
1400
- type Data = {
1401
- listener: 'bot:counter';
1402
- event: Event;
1403
- };
1404
- type Event = {
1405
- counter: string;
1406
- value: number;
1407
- };
1408
- }
1409
- namespace AlertService {
1410
- type Data = {
1411
- listener: 'alertService:toggleSound';
1412
- event: Event;
1413
- };
1414
- type Event = {
1415
- muted: boolean;
1416
- };
1417
- }
1418
- namespace EventSkip {
1419
- type Data = {
1420
- listener: 'event:skip';
1421
- event: Event;
1422
- };
1423
- type Event = {};
1424
- }
1425
- namespace EventTest {
1426
- export type Data = {
1427
- listener: 'event:test';
1428
- event: Event;
1429
- };
1430
- export type Event = widgetButton | emulatedEvents<EventType> | Session;
1431
- type items = {
1432
- name: string;
1433
- price: number;
1434
- quantity: number;
1435
- };
1436
- type widgetButton = {
1437
- listener: 'widget-button';
1438
- field: string;
1439
- value: string | number | boolean;
1440
- };
1441
- type EventType = 'follower' | 'subscriber' | 'tip' | 'cheer' | 'raid';
1442
- type EventTier = 'prime' | '1000' | '2000' | '3000';
1443
- type emulatedEvents<T extends EventType> = {
1444
- listener: `${T}-latest`;
1445
- event: {
1446
- type: T;
1447
- name: string;
1448
- amount: number;
1449
- count: number;
1450
- message?: string;
1451
- gifted?: boolean;
1452
- bulkGifted?: boolean;
1453
- sender?: string;
1454
- subExtension?: boolean;
1455
- items: items[];
1456
- tier: EventTier;
1457
- month: string;
1458
- isTest: true;
1459
- };
1460
- };
1461
- type Session = SessionCount | SessionTotal | SessionTop | SessionGoal | SessionRecent | SessionPoints;
1462
- type SessionCount = {
1463
- listener: `${EventType}-count`;
1464
- event: {
1465
- type: EventType;
1594
+ 'tip-session-top-donator': {
1466
1595
  name: string;
1467
- count: number;
1468
- items: items[];
1469
- tier: EventTier;
1470
- month: string;
1471
- isTest: true;
1596
+ amount: number;
1472
1597
  };
1473
- };
1474
- type SessionTotal = {
1475
- listener: `${EventType}-total`;
1476
- event: {
1477
- type: EventType;
1598
+ 'tip-weekly-top-donator': {
1478
1599
  name: string;
1479
1600
  amount: number;
1480
- count: number;
1481
- items: items[];
1482
- tier: EventTier;
1483
- month: string;
1484
- isTest: true;
1485
1601
  };
1486
- };
1487
- type SessionTop = {
1488
- listener: `${EventType}-top`;
1489
- event: {
1490
- type: EventType;
1602
+ 'tip-monthly-top-donator': {
1491
1603
  name: string;
1492
1604
  amount: number;
1493
- count: number;
1494
- items: items[];
1495
- tier: EventTier;
1496
- month: string;
1497
- isTest: true;
1498
1605
  };
1499
- };
1500
- type SessionGoal = {
1501
- listener: `${EventType}-goal`;
1502
- event: {
1503
- type: EventType;
1606
+ 'tip-alltime-top-donator': {
1504
1607
  name: string;
1505
1608
  amount: number;
1609
+ };
1610
+ 'tip-session': {
1611
+ amount: number;
1612
+ };
1613
+ 'tip-week': {
1614
+ amount: number;
1615
+ };
1616
+ 'tip-month': {
1617
+ amount: number;
1618
+ };
1619
+ 'tip-total': {
1620
+ amount: number;
1621
+ };
1622
+ 'tip-count': {
1506
1623
  count: number;
1507
- items: items[];
1508
- tier: EventTier;
1509
- month: string;
1510
- isTest: true;
1511
1624
  };
1512
- };
1513
- type SessionRecent = {
1514
- listener: `${EventType}-recent`;
1515
- event: {
1516
- event: SessionRecentEvent[];
1625
+ 'tip-goal': {
1626
+ amount: number;
1517
1627
  };
1518
- };
1519
- type SessionRecentEvent = {
1520
- type: EventType;
1521
- name: string;
1522
- amount: number;
1523
- count: number;
1524
- tier: EventTier;
1525
- isTest: true;
1526
- };
1527
- type SessionPoints = {
1528
- listener: `${EventType}-points`;
1529
- event: {
1530
- type: EventType;
1628
+ 'tip-recent': {
1531
1629
  name: string;
1532
1630
  amount: number;
1533
- count: number;
1534
- items: items[];
1535
- tier: EventTier;
1536
- month: string;
1537
- isTest: true;
1631
+ createdAt: string;
1632
+ }[];
1633
+ }
1634
+ interface Merch {
1635
+ 'merch-latest': {
1636
+ name: string;
1637
+ amount: number;
1638
+ items: any[];
1538
1639
  };
1539
- };
1540
- export {};
1541
- }
1542
- interface BaseEvent {
1543
- provider: Provider$1;
1544
- flagged: boolean;
1545
- channel: string;
1546
- createdAt: string;
1547
- _id: string;
1548
- expiresAt: string;
1549
- updatedAt: string;
1550
- activityId: string;
1551
- sessionEventsCount: number;
1552
- isMock?: boolean;
1553
- }
1554
- namespace Event {
1555
- type Data = {
1556
- listener: 'event';
1557
- event: Event;
1558
- };
1559
- type Event = Tip;
1560
- interface Tip extends BaseEvent {
1561
- type: 'tip';
1562
- data: {
1563
- amount: string;
1564
- currency: string;
1565
- username: string;
1566
- message: string;
1640
+ 'merch-goal-orders': {
1641
+ amount: number;
1642
+ };
1643
+ 'merch-goal-items': {
1644
+ amount: number;
1645
+ };
1646
+ 'merch-goal-total': {
1647
+ amount: number;
1648
+ };
1649
+ 'merch-recent': {
1650
+ name: string;
1651
+ }[];
1652
+ }
1653
+ interface Purchase {
1654
+ 'purchase-latest': {
1655
+ name: string;
1656
+ amount: number;
1657
+ items: any[];
1567
1658
  avatar: string;
1659
+ message: string;
1568
1660
  };
1569
1661
  }
1570
1662
  }
1571
1663
  }
1572
1664
 
1573
- type TwitchEmote = {
1574
- type: 'twitch';
1575
- name: string;
1576
- id: string;
1577
- gif: boolean;
1578
- urls: {
1579
- '1': string;
1580
- '2': string;
1581
- '4': string;
1582
- };
1583
- start: number;
1584
- end: number;
1665
+ interface CommandOptions {
1666
+ prefix?: string;
1667
+ name: string;
1668
+ description?: string;
1669
+ arguments?: boolean;
1670
+ run: (this: Client, args: string[], event: CommandEvent) => void;
1671
+ test?: string;
1672
+ aliases?: string[];
1673
+ permissions?: string[] | boolean;
1674
+ admins?: string[];
1675
+ }
1676
+ type CommandEvent = {
1677
+ provider: 'twitch';
1678
+ data: StreamElements.Event.Provider.Twitch.Message;
1679
+ } | {
1680
+ provider: 'youtube';
1681
+ data: StreamElements.Event.Provider.YouTube.Message;
1682
+ } | {
1683
+ provider: 'kick';
1684
+ data: any;
1685
+ };
1686
+ declare class Command {
1687
+ prefix: string;
1688
+ name: string;
1689
+ description: string;
1690
+ arguments: boolean;
1691
+ test: string | (() => string);
1692
+ aliases: string[];
1693
+ permissions?: string[] | boolean;
1694
+ admins: string[];
1695
+ constructor(options: CommandOptions);
1696
+ run(this: Client | undefined, args: string[], event: CommandEvent): void;
1697
+ verify(nickname: string, roles: string[], args: string[]): boolean;
1698
+ parse(text: string, event: CommandEvent): boolean;
1699
+ remove(): void;
1700
+ static execute(received: CommandEvent): boolean;
1701
+ }
1702
+
1703
+ /**
1704
+ * EventProvider class for managing event listeners and emitters.
1705
+ * This class allows you to register event listeners, emit events, and manage event subscriptions.
1706
+ * @example
1707
+ * ```typescript
1708
+ * type TestEvents = {
1709
+ * load: [event: { type: 'load' }];
1710
+ * event: [event: { type: 'event' }];
1711
+ * };
1712
+ *
1713
+ * class Test extends EventProvider<TestEvents> {}
1714
+ *
1715
+ * const test = new Test();
1716
+ * test.once('load', (data) => {});
1717
+ * test.emit('load', { type: 'load' });
1718
+ *
1719
+ * test.on('event', (data) => {});
1720
+ * test.emit('event', { type: 'event' });
1721
+ * ```
1722
+ */
1723
+ declare class EventProvider<EventMap extends Record<string, any[]> = Record<string, any[]>> {
1724
+ /**
1725
+ * Stores registered event listeners.
1726
+ */
1727
+ private registeredEvents;
1728
+ /**
1729
+ * Emits an event to all registered listeners.
1730
+ * Returns an array of return values from the listeners.
1731
+ * @param eventName The name of the event.
1732
+ * @param args Arguments to pass to the listeners.
1733
+ */
1734
+ emit<K extends keyof EventMap>(eventName: K, ...args: EventMap[K]): any[];
1735
+ /**
1736
+ * Registers an event listener.
1737
+ * @param eventName The name of the event.
1738
+ * @param callback The callback function.
1739
+ */
1740
+ on<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
1741
+ /**
1742
+ * Removes a specific event listener.
1743
+ * @param eventName The name of the event.
1744
+ * @param callback The callback function to remove.
1745
+ */
1746
+ off<K extends keyof EventMap>(eventName: K, callback?: (this: this, ...args: EventMap[K]) => any): this;
1747
+ /**
1748
+ * Registers a listener that is executed only once.
1749
+ * @param eventName The name of the event.
1750
+ * @param callback The callback function.
1751
+ */
1752
+ once<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
1753
+ /**
1754
+ * Removes all listeners for a specific event.
1755
+ * @param eventName The name of the event.
1756
+ */
1757
+ removeAllListeners<K extends keyof EventMap>(eventName: K): this;
1758
+ }
1759
+
1760
+ type JSONPrimitive = string | number | boolean | null;
1761
+ type JSONSerializable = JSONPrimitive | JSONSerializable[] | {
1762
+ [k: string]: JSONSerializable | undefined;
1763
+ };
1764
+ type JSONObject = {
1765
+ [key: string]: JSONSerializable | undefined;
1766
+ };
1767
+
1768
+ type UseStorageEvents<T> = {
1769
+ load: [T | null];
1770
+ update: [T];
1771
+ };
1772
+ type UseStorageOptions<T> = {
1773
+ id?: string;
1774
+ data: T;
1775
+ };
1776
+ declare class useStorage<T extends JSONObject> extends EventProvider<UseStorageEvents<T>> {
1777
+ private SE_API;
1778
+ /** The unique identifier for the storage instance. */
1779
+ id: string;
1780
+ loaded: boolean;
1781
+ data: T;
1782
+ constructor(options: UseStorageOptions<T>);
1783
+ /**
1784
+ * Saves the current data to storage.
1785
+ * @param data Data to save (defaults to current)
1786
+ */
1787
+ private save;
1788
+ /**
1789
+ * Updates the storage data and emits an update event
1790
+ * @param data Data to update (defaults to current)
1791
+ */
1792
+ update(data?: Partial<T>): void;
1793
+ /**
1794
+ * Adds a value to the storage at the specified path.
1795
+ * @param path Path to add the value to
1796
+ * @param value Value to add
1797
+ */
1798
+ add<P extends string>(path: P, value: PathValue<T, P>): void;
1799
+ /**
1800
+ * Clears all data from the storage.
1801
+ */
1802
+ clear(): void;
1803
+ /**
1804
+ * Sets a value in the storage at the specified path.
1805
+ * @param obj The object to set the value in
1806
+ * @param path The path to set the value at
1807
+ * @param value The value to set
1808
+ * @returns The updated object
1809
+ */
1810
+ static setByPath<P extends string, T extends object>(obj: T, path: P, value: PathValue<T, P>): void;
1811
+ on<K extends keyof UseStorageEvents<T>>(eventName: K, callback: (this: useStorage<T>, ...args: UseStorageEvents<T>[K]) => void): this;
1812
+ }
1813
+
1814
+ declare namespace Alejo {
1815
+ namespace Pronouns {
1816
+ type name = 'hehim' | 'sheher' | 'theythem' | 'shethem' | 'hethem' | 'heshe' | 'xexem' | 'faefaer' | 'vever' | 'aeaer' | 'ziehir' | 'perper' | 'eem' | 'itits';
1817
+ type display = 'He/Him' | 'She/Her' | 'They/Them' | 'She/They' | 'He/They' | 'He/She' | 'Xe/Xem' | 'Fae/Faer' | 'Ve/Ver' | 'Ae/Aer' | 'Zie/Hir' | 'Per/Per' | 'E/Em' | 'It/Its';
1818
+ enum map {
1819
+ hehim = "He/Him",
1820
+ sheher = "She/Her",
1821
+ theythem = "They/Them",
1822
+ shethem = "She/They",
1823
+ hethem = "He/They",
1824
+ heshe = "He/She",
1825
+ xexem = "Xe/Xem",
1826
+ faefaer = "Fae/Faer",
1827
+ vever = "Ve/Ver",
1828
+ aeaer = "Ae/Aer",
1829
+ ziehir = "Zie/Hir",
1830
+ perper = "Per/Per",
1831
+ eem = "E/Em",
1832
+ itits = "It/Its"
1833
+ }
1834
+ }
1835
+ function list(): Promise<typeof Pronouns.map>;
1836
+ type user = {
1837
+ id: string;
1838
+ login: string;
1839
+ pronoun_id: Pronouns.name;
1840
+ };
1841
+ function get(username: string): Promise<Pronouns.name | undefined>;
1842
+ }
1843
+
1844
+ type ClientEvents = {
1845
+ load: [event: StreamElements.Event.onWidgetLoad];
1846
+ action: [action: Button | Command, type: 'created' | 'executed' | 'removed'];
1847
+ session: [session: StreamElements.Session.Data];
1848
+ event: [provider: 'streamelements', event: StreamElements.Event.Provider.StreamElements.Events] | [provider: 'twitch', event: StreamElements.Event.Provider.Twitch.Events] | [provider: 'youtube', event: StreamElements.Event.Provider.YouTube.Events] | [provider: 'kick', event: StreamElements.Event.Provider.Kick.Events] | [provider: 'facebook', event: StreamElements.Event.Provider.Facebook.Events];
1585
1849
  };
1586
- type SeventvEmote = {
1587
- type: '7tv';
1588
- name: string;
1589
- id: string;
1590
- gif: boolean;
1591
- animated: boolean;
1592
- urls: {
1593
- '1': string;
1594
- '2': string;
1595
- '3': string;
1596
- '4': string;
1597
- };
1598
- start: number;
1599
- end: number;
1600
- cords: {
1601
- x: number;
1602
- y: number;
1603
- };
1850
+ type ClientStorageOptions<T> = {
1851
+ value: T;
1852
+ timestamp: number;
1853
+ expire: number;
1604
1854
  };
1605
- type BttvEmote = {
1606
- type: 'bttv';
1607
- name: string;
1855
+ type ClientStorage = {
1856
+ user: Record<string, ClientStorageOptions<string>>;
1857
+ avatar: Record<string, ClientStorageOptions<string>>;
1858
+ pronoun: Record<string, ClientStorageOptions<Alejo.Pronouns.name>>;
1859
+ emote: Record<string, ClientStorageOptions<string>>;
1860
+ };
1861
+ type ClientOptions = {
1862
+ id?: string;
1863
+ debug?: boolean | (() => boolean);
1864
+ };
1865
+ declare class Client extends EventProvider<ClientEvents> {
1608
1866
  id: string;
1609
- gif: boolean;
1610
- animated: boolean;
1611
- urls: {
1612
- '1': string;
1613
- '2': string;
1614
- '4': string;
1867
+ debug: boolean;
1868
+ storage: useStorage<ClientStorage>;
1869
+ fields: StreamElements.Event.onWidgetLoad['fieldData'];
1870
+ session: StreamElements.Session.Data;
1871
+ loaded: boolean;
1872
+ constructor(options: ClientOptions);
1873
+ actions: {
1874
+ commands: Command[];
1875
+ buttons: Button[];
1615
1876
  };
1616
- start: number;
1617
- end: number;
1618
- coords: {
1619
- x: number;
1620
- y: number;
1621
- width: number;
1622
- height: number;
1877
+ details: {
1878
+ provider: Provider$1 | 'local';
1879
+ user: StreamElements.Event.onWidgetLoad['channel'];
1880
+ currency: StreamElements.Event.onWidgetLoad['currency'];
1881
+ overlay: StreamElements.Event.onWidgetLoad['overlay'];
1623
1882
  };
1624
- };
1625
- type Emoji = {
1626
- type: 'emoji';
1627
- name: string;
1628
- id: string;
1629
- gif: boolean;
1630
- urls: {
1631
- '1': string;
1883
+ cache: {
1884
+ /**
1885
+ * Avatar cache duration in minutes.
1886
+ */
1887
+ avatar: number;
1888
+ /**
1889
+ * Pronoun cache duration in minutes.
1890
+ */
1891
+ pronoun: number;
1892
+ /**
1893
+ * Emote cache duration in minutes.
1894
+ */
1895
+ emote: number;
1632
1896
  };
1633
- };
1634
- type Emote = TwitchEmote | BttvEmote | SeventvEmote | Emoji;
1897
+ on<K extends keyof ClientEvents>(eventName: K, callback: (this: Client, ...args: ClientEvents[K]) => void): this;
1898
+ }
1899
+
1900
+ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
1901
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
1902
+ }[Keys];
1903
+
1904
+ interface ButtonOptions {
1905
+ field: string | ((field: string, value: string | boolean | number) => boolean);
1906
+ template?: string;
1907
+ name?: string;
1908
+ value?: string;
1909
+ run: (this: Client | undefined, field: string, value: string | boolean | number) => void;
1910
+ }
1911
+ /**
1912
+ * Represents a button action that can be triggered by custom fields in StreamElements.
1913
+ * The button can be configured with a template and a name, and it will execute a specified function when triggered.
1914
+ * @example
1915
+ * ```javascript
1916
+ * const button = new Button({
1917
+ * field: (field, value) => field.startsWith('message-') && field.split('-')[1],
1918
+ * template: 'message-{role}',
1919
+ * // name: '[CAP={role}] role message',
1920
+ * name: 'Generate {role} message',
1921
+ * run(field, value) {
1922
+ * console.log(`Button ${field} was clicked with value: ${value}`);
1923
+ * }
1924
+ * })
1925
+ *
1926
+ * const field = button.generate([{ role: 'broadcaster' }, { role: 'moderator' }]);
1927
+ * // This will create buttons with fields "message-broadcaster" and "message-moderator" and names "Generate broadcaster message" and "Generate moderator message".
1928
+ * // field['message-broadcaster'] => { type: 'button', label: 'Generate broadcaster message' }
1929
+ * // field['message-moderator'] => { type: 'button', label: 'Generate moderator message' }
1930
+ *
1931
+ * // When a custom field with the name "message-broadcaster" or "message-moderator" is triggered, the run function will be called with the field and value.
1932
+ * ```
1933
+ */
1934
+ declare class Button {
1935
+ field: ButtonOptions['field'];
1936
+ template: string;
1937
+ name: string;
1938
+ value: string;
1939
+ run: ButtonOptions['run'];
1940
+ constructor(options: ButtonOptions);
1941
+ generate(values: Array<Record<string, string | number>>): Record<string, StreamElements.CustomField.Schema>;
1942
+ parse(field: string, value: string | boolean | number): Button;
1943
+ remove(): void;
1944
+ static execute(field: string, value: string | boolean | number): boolean;
1945
+ }
1946
+
1947
+ interface Theme {
1948
+ color?: string;
1949
+ background?: string;
1950
+ bold?: boolean;
1951
+ italic?: boolean;
1952
+ fontSize?: number;
1953
+ icon?: string;
1954
+ }
1955
+ interface Options {
1956
+ enabled?: boolean;
1957
+ prefix?: string | (() => string);
1958
+ }
1959
+ type LogMethod = (...args: unknown[]) => void;
1960
+ declare class useLogger {
1961
+ enabled: boolean;
1962
+ prefix: string | (() => string);
1963
+ constructor(options?: Options);
1964
+ apply(theme: Theme): LogMethod;
1965
+ private style;
1966
+ group(label: string): void;
1967
+ groupCollapsed(label: string): void;
1968
+ groupEnd(): void;
1969
+ table(data: unknown): void;
1970
+ time(label: string): void;
1971
+ timeEnd(label: string): void;
1972
+ readonly error: LogMethod;
1973
+ readonly warn: LogMethod;
1974
+ readonly success: LogMethod;
1975
+ readonly info: LogMethod;
1976
+ readonly debug: LogMethod;
1977
+ readonly alert: LogMethod;
1978
+ readonly status: LogMethod;
1979
+ readonly received: LogMethod;
1980
+ readonly simple: LogMethod;
1981
+ }
1635
1982
 
1983
+ type QueueEvents<T> = {
1984
+ load: [];
1985
+ cancel: [];
1986
+ update: [
1987
+ queue: QueueItem<T>[],
1988
+ priorityQueue: QueueItem<T>[],
1989
+ history: QueueItem<T>[],
1990
+ timeouts: Array<ReturnType<typeof setTimeout>>
1991
+ ];
1992
+ process: [item: QueueItem<T>, queue: useQueue<T>];
1993
+ };
1994
+ type QueueProps = {
1995
+ isoDate: string;
1996
+ isLoop: boolean;
1997
+ isPriority: boolean;
1998
+ isImmediate: boolean;
1999
+ };
2000
+ type QueueItem<T> = {
2001
+ value: T;
2002
+ } & QueueProps;
2003
+ type QueueProcessor<T> = (this: useQueue<T>, item: T, queue: useQueue<T>) => Promise<any>;
2004
+ type QueueDuration = number | boolean | undefined;
2005
+ interface QueueOptions<T> {
2006
+ /**
2007
+ * Duration between processing each item in milliseconds. Set to `0` or `false` for immediate processing.
2008
+ */
2009
+ duration?: QueueDuration | 'client';
2010
+ /**
2011
+ * Function to process each item in the queue.
2012
+ */
2013
+ processor: QueueProcessor<T>;
2014
+ }
1636
2015
  /**
1637
- * EventProvider class for managing event listeners and emitters.
1638
- * This class allows you to register event listeners, emit events, and manage event subscriptions.
2016
+ * A utility class to manage a queue of items with support for priority, looping, and immediate processing.
2017
+ * @template T - The type of items in the queue.
2018
+ * @extends EventProvider<QueueEvents<T>>
1639
2019
  * @example
1640
- * ```typescript
1641
- * type TestEvents = {
1642
- * load: [event: { type: 'load' }];
1643
- * event: [event: { type: 'event' }];
1644
- * };
1645
- *
1646
- * class Test extends EventProvider<TestEvents> {}
1647
- *
1648
- * const test = new Test();
1649
- * test.once('load', (data) => {});
1650
- * test.emit('load', { type: 'load' });
2020
+ * ```javascript
2021
+ * const myQueue = new useQueue({
2022
+ * duration: 1000,
2023
+ * processor: async function (item) {
2024
+ * console.log('Processing item:', item);
2025
+ * },
2026
+ * });
1651
2027
  *
1652
- * test.on('event', (data) => {});
1653
- * test.emit('event', { type: 'event' });
2028
+ * myQueue.enqueue('Item 1');
2029
+ * myQueue.enqueue('Item 2', { isPriority: true });
1654
2030
  * ```
1655
2031
  */
1656
- declare class EventProvider<EventMap extends Record<string, any[]> = Record<string, any[]>> {
2032
+ declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
2033
+ queue: QueueItem<T>[];
2034
+ priorityQueue: QueueItem<T>[];
2035
+ history: QueueItem<T>[];
2036
+ private timeouts;
2037
+ running: boolean;
2038
+ duration: QueueDuration;
2039
+ private loaded;
2040
+ processor: QueueProcessor<T>;
2041
+ private readonly clientWaitRetryDelay;
2042
+ constructor(options: QueueOptions<T>);
2043
+ private waitForClientAndBindLoad;
1657
2044
  /**
1658
- * Stores registered event listeners.
2045
+ * Enqueue an item or multiple items into the queue with optional processing options.
2046
+ * @param value - The item or items to be enqueued. Can be a single value of type T or an array of objects containing the value and options.
2047
+ * @param options - Optional processing options for the item(s) being enqueued. Ignored if an array of items is provided, as each item can have its own options.
2048
+ * @returns The instance of the queue for chaining.
2049
+ * @example
2050
+ * ```javascript
2051
+ * myQueue.enqueue('Single Item', { isPriority: true });
2052
+ * myQueue.enqueue([
2053
+ * { value: 'Item 1', options: { isPriority: true } },
2054
+ * { value: 'Item 2', options: { isLoop: true } }
2055
+ * ]);
2056
+ * ```
1659
2057
  */
1660
- private registeredEvents;
2058
+ enqueue(value: T, options?: Partial<QueueProps>): this;
2059
+ enqueue(items: {
2060
+ value: T;
2061
+ options?: Partial<QueueProps>;
2062
+ }[]): this;
2063
+ private run;
2064
+ private next;
1661
2065
  /**
1662
- * Emits an event to all registered listeners.
1663
- * Returns an array of return values from the listeners.
1664
- * @param eventName The name of the event.
1665
- * @param args Arguments to pass to the listeners.
2066
+ * Resume processing the queue if it is paused. If the queue is already running, it will be restarted, which can be useful if new items have been added or if you want to reset the processing timer.
2067
+ * If the queue was empty before, it will start processing immediately.
2068
+ * @returns - The instance of the queue for chaining.
2069
+ * @example
2070
+ * ```javascript
2071
+ * myQueue.resume();
2072
+ * ```
1666
2073
  */
1667
- emit<K extends keyof EventMap>(eventName: K, ...args: EventMap[K]): any[];
2074
+ resume(): this;
1668
2075
  /**
1669
- * Registers an event listener.
1670
- * @param eventName The name of the event.
1671
- * @param callback The callback function.
2076
+ * Update the queue's state with new values. This can be used to replace the current queue, priority queue, history, or timeouts with new data. If the queue is not currently running and there are items in the queue after the update, it will start processing immediately.
2077
+ * @param save - An object containing the new state for the queue, priority queue, history, and timeouts. Each property is optional, and if not provided, the current state will be retained.
2078
+ * @returns - The instance of the queue for chaining.
2079
+ * @example
2080
+ * ```javascript
2081
+ * myQueue.update({
2082
+ * queue: newQueueItems,
2083
+ * priorityQueue: newPriorityItems,
2084
+ * history: newHistory,
2085
+ * });
2086
+ * ```
1672
2087
  */
1673
- on<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
2088
+ update(save: Partial<useQueue<T>>): this;
1674
2089
  /**
1675
- * Removes a specific event listener.
1676
- * @param eventName The name of the event.
1677
- * @param callback The callback function to remove.
2090
+ * Cancel all pending timeouts and stop the queue from processing further items. This will clear any scheduled processing and prevent any new items from being processed until `resume()` is called again. The current state of the queue, priority queue, and history will be retained, allowing you to resume processing later without losing any data.
1678
2091
  */
1679
- off<K extends keyof EventMap>(eventName: K, callback?: (this: this, ...args: EventMap[K]) => any): this;
2092
+ cancel(): void;
1680
2093
  /**
1681
- * Registers a listener that is executed only once.
1682
- * @param eventName The name of the event.
1683
- * @param callback The callback function.
2094
+ * Check if there are any items in the queue or priority queue. This method returns `true` if there are items waiting to be processed in either the main queue or the priority queue, and `false` if both queues are empty.
2095
+ * @returns - A boolean indicating whether there are items in the queue or priority queue.
1684
2096
  */
1685
- once<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
2097
+ hasItems(): boolean;
2098
+ on<K extends keyof QueueEvents<T>>(eventName: K, callback: (this: useQueue<T>, ...args: QueueEvents<T>[K]) => void): this;
2099
+ }
2100
+
2101
+ type ComfyEvents = {
2102
+ load: [instance: ComfyJSInstance];
2103
+ error: Parameters<OnErrorHandler>;
2104
+ command: Parameters<OnCommandHandler>;
2105
+ chat: Parameters<OnChatHandler>;
2106
+ whisper: Parameters<OnWhisperHandler>;
2107
+ messageDeleted: Parameters<OnMessageDeletedHandler>;
2108
+ join: Parameters<OnJoinHandler>;
2109
+ part: Parameters<OnPartHandler>;
2110
+ hosted: Parameters<OnHostedHandler>;
2111
+ raid: Parameters<OnRaidHandler>;
2112
+ sub: Parameters<OnSubHandler>;
2113
+ resub: Parameters<OnResubHandler>;
2114
+ subGift: Parameters<OnSubGiftHandler>;
2115
+ subMysteryGift: Parameters<OnSubMysteryGiftHandler>;
2116
+ giftSubContinue: Parameters<OnGiftSubContinueHandler>;
2117
+ cheer: Parameters<OnCheerHandler>;
2118
+ chatMode: Parameters<OnChatModeHandler>;
2119
+ reward: Parameters<OnRewardHandler>;
2120
+ connected: Parameters<OnConnectedHandler>;
2121
+ reconnect: Parameters<OnReconnectHandler>;
2122
+ };
2123
+ /**
2124
+ * Creates and manages a ComfyJS instance for Twitch chat interaction.
2125
+ */
2126
+ declare class useComfyJs extends EventProvider<ComfyEvents> {
2127
+ instance: ComfyJSInstance;
2128
+ username: string;
2129
+ password?: string;
2130
+ channels: string[];
2131
+ isDebug: boolean;
2132
+ private init;
2133
+ emulate: boolean;
1686
2134
  /**
1687
- * Removes all listeners for a specific event.
1688
- * @param eventName The name of the event.
2135
+ * Initializes a new ComfyJS instance and connects to Twitch chat.
2136
+ * @param options - Configuration options for ComfyJS instance.
2137
+ * @param emulate - Whether to emulate chat messages in the Local module.
1689
2138
  */
1690
- removeAllListeners<K extends keyof EventMap>(eventName: K): this;
2139
+ constructor(options: {
2140
+ username: string;
2141
+ password?: string;
2142
+ channels: string[];
2143
+ isDebug?: boolean;
2144
+ init?: boolean;
2145
+ }, emulate: boolean);
2146
+ /**
2147
+ * Loads the ComfyJS script if not already loaded.
2148
+ * @returns A promise that resolves to the ComfyJS instance.
2149
+ */
2150
+ private load;
2151
+ /**
2152
+ * Connects event handlers to the ComfyJS instance.
2153
+ */
2154
+ private connect;
1691
2155
  }
1692
2156
 
1693
- type JSONPrimitive = string | number | boolean | null;
1694
- type JSONSerializable = JSONPrimitive | JSONSerializable[] | {
1695
- [k: string]: JSONSerializable | undefined;
1696
- };
1697
- type JSONObject = {
1698
- [key: string]: JSONSerializable | undefined;
1699
- };
2157
+ declare namespace Data {
2158
+ const avatars: string[];
2159
+ const badges: Twitch.GlobalBadge[];
2160
+ const css_color_names: string[];
2161
+ const items: any[];
2162
+ const names: string[];
2163
+ const tiers: string[];
2164
+ const tts: string[];
2165
+ const messages: string[];
2166
+ const normal_messages: string[];
2167
+ const twitch_messages: string[];
2168
+ const youtube_messages: string[];
2169
+ const emotes: (TwitchEmote | BttvEmote | SeventvEmote)[];
2170
+ const ffz_emotes: {
2171
+ id: string;
2172
+ name: string;
2173
+ platform: string;
2174
+ animated: boolean;
2175
+ urls: {
2176
+ '1': string;
2177
+ '2': string;
2178
+ '4': string;
2179
+ };
2180
+ }[];
2181
+ const bttv_emotes: {
2182
+ id: string;
2183
+ name: string;
2184
+ platform: string;
2185
+ animated: boolean;
2186
+ urls: {
2187
+ '1': string;
2188
+ '2': string;
2189
+ '4': string;
2190
+ };
2191
+ }[];
2192
+ const seventv_emotes: {
2193
+ id: string;
2194
+ name: string;
2195
+ platform: string;
2196
+ animated: boolean;
2197
+ urls: {
2198
+ '1': string;
2199
+ '2': string;
2200
+ '3': string;
2201
+ '4': string;
2202
+ };
2203
+ }[];
2204
+ const twitch_emotes: ({
2205
+ type: string;
2206
+ name: string;
2207
+ id: string;
2208
+ gif: boolean;
2209
+ animated: boolean;
2210
+ urls: {
2211
+ '1': string;
2212
+ '2': string;
2213
+ '4': string;
2214
+ };
2215
+ start: number;
2216
+ end: number;
2217
+ } | {
2218
+ type: string;
2219
+ name: string;
2220
+ id: string;
2221
+ gif: boolean;
2222
+ urls: {
2223
+ '1': string;
2224
+ '2': string;
2225
+ '4': string;
2226
+ };
2227
+ start: number;
2228
+ end: number;
2229
+ animated?: undefined;
2230
+ })[];
2231
+ const youtube_emotes: {
2232
+ emojiId: string;
2233
+ shortcuts: string[];
2234
+ searchTerms: string[];
2235
+ image: {
2236
+ thumbnails: {
2237
+ url: string;
2238
+ width: number;
2239
+ height: number;
2240
+ }[];
2241
+ accessibility: {
2242
+ accessibilityData: {
2243
+ label: string;
2244
+ };
2245
+ };
2246
+ };
2247
+ isCustomEmoji: boolean;
2248
+ index: number;
2249
+ }[];
2250
+ }
1700
2251
 
1701
- type UseStorageEvents<T> = {
1702
- load: [T | null];
1703
- update: [T];
1704
- };
1705
- type UseStorageOptions<T> = {
1706
- id?: string;
1707
- data: T;
1708
- };
1709
- declare class useStorage<T extends JSONObject> extends EventProvider<UseStorageEvents<T>> {
1710
- private SE_API;
1711
- /** The unique identifier for the storage instance. */
1712
- id: string;
1713
- loaded: boolean;
1714
- data: T;
1715
- constructor(options: UseStorageOptions<T>);
2252
+ /**
2253
+ * NumberHelper class provides utility methods for working with numbers, including translation to words, balancing within a range, rounding, and generating random numbers.
2254
+ */
2255
+ declare class NumberHelper {
2256
+ /**
2257
+ * Translate number to words
2258
+ * @param num - Number to translate
2259
+ * @param type - Translation type
2260
+ * @returns - Number in words
2261
+ * @example
2262
+ * ```javascript
2263
+ * const cardinal = translate(42, 'cardinal');
2264
+ * console.log(cardinal); // "forty-two"
2265
+ * const ordinal = translate(42, 'ordinal');
2266
+ * console.log(ordinal); // "forty-second"
2267
+ * const suffix = translate(42, 'suffix');
2268
+ * console.log(suffix); // "42nd"
2269
+ * ```
2270
+ */
2271
+ translate(num: number, type?: 'cardinal' | 'ordinal' | 'suffix'): string;
2272
+ /**
2273
+ * Balances a number within a specified range
2274
+ * @param amount - Number to balance
2275
+ * @param min - Minimum value
2276
+ * @param max - Maximum value
2277
+ * @param decimals - Number of decimal places to round to (default is 0)
2278
+ * @returns - Balanced number
2279
+ * @example
2280
+ * ```javascript
2281
+ * const balancedValue = balance(150, 0, 100);
2282
+ * console.log(balancedValue); // 100
2283
+ * ```
2284
+ */
2285
+ balance(amount: number, min?: number, max?: number, decimals?: number): number;
2286
+ /**
2287
+ * Rounds a number to a specified number of decimal places
2288
+ * @param value - Number to round
2289
+ * @param decimals - Number of decimal places (default is 2)
2290
+ * @returns Rounded number
2291
+ * @example
2292
+ * ```javascript
2293
+ * const roundedValue = round(3.14159, 3);
2294
+ * console.log(roundedValue); // 3.142
2295
+ * const roundedValueDefault = round(3.14159);
2296
+ * console.log(roundedValueDefault); // 3.14
2297
+ * const roundedValueZero = round(3.14159, 0);
2298
+ * console.log(roundedValueZero); // 3
2299
+ * ```
2300
+ */
2301
+ round(value: number, decimals?: number): number;
2302
+ /**
2303
+ * Generate random number
2304
+ * @param min - Minimum value
2305
+ * @param max - Maximum value
2306
+ * @param float - Number of decimal places (0 for integer)
2307
+ * @returns - Random number
2308
+ * @example
2309
+ * ```javascript
2310
+ * const intNumber = random(1, 10);
2311
+ * console.log(intNumber); // e.g. 7
2312
+ *
2313
+ * const floatNumber = random(1, 10, 2);
2314
+ * console.log(floatNumber); // e.g. 3.14
2315
+ * ```
2316
+ */
2317
+ random(min: number, max: number, float?: number): number;
2318
+ }
2319
+
2320
+ interface ScaleOptions<T extends HTMLElement> {
1716
2321
  /**
1717
- * Saves the current data to storage.
1718
- * @param data Data to save (defaults to current)
2322
+ * The parent element to use for scaling calculations. If not provided, the element's parent will be used.
1719
2323
  */
1720
- private save;
2324
+ parent?: HTMLElement;
1721
2325
  /**
1722
- * Updates the storage data and emits an update event
1723
- * @param data Data to update (defaults to current)
2326
+ * The preferred dimension to base the scaling on. Can be 'width', 'height', or 'auto' (default).
1724
2327
  */
1725
- update(data?: Partial<T>): void;
2328
+ prefer?: 'width' | 'height' | 'auto';
1726
2329
  /**
1727
- * Adds a value to the storage at the specified path.
1728
- * @param path Path to add the value to
1729
- * @param value Value to add
2330
+ * The minimum percentage of the parent size to scale to. Default is 0.
1730
2331
  */
1731
- add<P extends string>(path: P, value: PathValue<T, P>): void;
2332
+ min?: number;
1732
2333
  /**
1733
- * Clears all data from the storage.
2334
+ * The maximum percentage of the parent size to scale to. Default is 1 (100%).
1734
2335
  */
1735
- clear(): void;
2336
+ max?: number;
1736
2337
  /**
1737
- * Sets a value in the storage at the specified path.
1738
- * @param obj The object to set the value in
1739
- * @param path The path to set the value at
1740
- * @param value The value to set
1741
- * @returns The updated object
2338
+ * A callback function that is called after scaling is applied.
2339
+ * @param this - The HTML element being scaled.
2340
+ * @param number - The scale factor applied to the element.
2341
+ * @param element - The HTML element being scaled.
2342
+ * @returns void
1742
2343
  */
1743
- static setByPath<P extends string, T extends object>(obj: T, path: P, value: PathValue<T, P>): void;
1744
- on<K extends keyof UseStorageEvents<T>>(eventName: K, callback: (this: useStorage<T>, ...args: UseStorageEvents<T>[K]) => void): this;
1745
- }
1746
-
1747
- interface CommandOptions {
1748
- prefix?: string;
1749
- name: string;
1750
- description?: string;
1751
- arguments?: boolean;
1752
- run: (this: Client, args: string[], event: CommandEvent) => void;
1753
- test?: string;
1754
- aliases?: string[];
1755
- permissions?: string[] | boolean;
1756
- admins?: string[];
1757
- }
1758
- type CommandEvent = {
1759
- provider: 'twitch';
1760
- data: StreamElements.Event.Provider.Twitch.Message;
1761
- } | {
1762
- provider: 'youtube';
1763
- data: StreamElements.Event.Provider.YouTube.Message;
1764
- } | {
1765
- provider: 'kick';
1766
- data: any;
1767
- };
1768
- declare class Command {
1769
- prefix: string;
1770
- name: string;
1771
- description: string;
1772
- arguments: boolean;
1773
- test: string | (() => string);
1774
- aliases: string[];
1775
- permissions?: string[] | boolean;
1776
- admins: string[];
1777
- constructor(options: CommandOptions);
1778
- run(this: Client | undefined, args: string[], event: CommandEvent): void;
1779
- verify(nickname: string, roles: string[], args: string[]): boolean;
1780
- parse(text: string, event: CommandEvent): boolean;
1781
- remove(): void;
1782
- static execute(received: CommandEvent): boolean;
1783
- }
1784
-
1785
- declare namespace Alejo {
1786
- namespace Pronouns {
1787
- type name = 'hehim' | 'sheher' | 'theythem' | 'shethem' | 'hethem' | 'heshe' | 'xexem' | 'faefaer' | 'vever' | 'aeaer' | 'ziehir' | 'perper' | 'eem' | 'itits';
1788
- type display = 'He/Him' | 'She/Her' | 'They/Them' | 'She/They' | 'He/They' | 'He/She' | 'Xe/Xem' | 'Fae/Faer' | 'Ve/Ver' | 'Ae/Aer' | 'Zie/Hir' | 'Per/Per' | 'E/Em' | 'It/Its';
1789
- enum map {
1790
- hehim = "He/Him",
1791
- sheher = "She/Her",
1792
- theythem = "They/Them",
1793
- shethem = "She/They",
1794
- hethem = "He/They",
1795
- heshe = "He/She",
1796
- xexem = "Xe/Xem",
1797
- faefaer = "Fae/Faer",
1798
- vever = "Ve/Ver",
1799
- aeaer = "Ae/Aer",
1800
- ziehir = "Zie/Hir",
1801
- perper = "Per/Per",
1802
- eem = "E/Em",
1803
- itits = "It/Its"
1804
- }
1805
- }
1806
- function list(): Promise<typeof Pronouns.map>;
1807
- type user = {
1808
- id: string;
1809
- login: string;
1810
- pronoun_id: Pronouns.name;
1811
- };
1812
- function get(username: string): Promise<Pronouns.name | undefined>;
2344
+ apply?: (this: T, number: number, element: T) => void;
1813
2345
  }
1814
-
1815
- type ClientEvents = {
1816
- load: [event: StreamElements.Event.onWidgetLoad];
1817
- action: [action: Button | Command, type: 'created' | 'executed' | 'removed'];
1818
- session: [session: StreamElements.Session.Data];
1819
- event: [provider: 'streamelements', event: StreamElements.Event.Provider.StreamElements.Events] | [provider: 'twitch', event: StreamElements.Event.Provider.Twitch.Events] | [provider: 'youtube', event: StreamElements.Event.Provider.YouTube.Events] | [provider: 'kick', event: StreamElements.Event.Provider.Kick.Events] | [provider: 'facebook', event: StreamElements.Event.Provider.Facebook.Events];
1820
- };
1821
- type ClientStorageOptions<T> = {
1822
- value: T;
1823
- timestamp: number;
1824
- expire: number;
1825
- };
1826
- type ClientStorage = {
1827
- user: Record<string, ClientStorageOptions<string>>;
1828
- avatar: Record<string, ClientStorageOptions<string>>;
1829
- pronoun: Record<string, ClientStorageOptions<Alejo.Pronouns.name>>;
1830
- emote: Record<string, ClientStorageOptions<string>>;
1831
- };
1832
- type ClientOptions = {
1833
- id?: string;
1834
- debug?: boolean | (() => boolean);
2346
+ type FitTextOptions = {
2347
+ minFontSize?: number;
2348
+ maxFontSize?: number;
2349
+ parent?: HTMLElement;
1835
2350
  };
1836
- declare class Client extends EventProvider<ClientEvents> {
1837
- id: string;
1838
- debug: boolean;
1839
- storage: useStorage<ClientStorage>;
1840
- fields: StreamElements.Event.onWidgetLoad['fieldData'];
1841
- session: StreamElements.Session.Data;
1842
- loaded: boolean;
1843
- constructor(options: ClientOptions);
1844
- actions: {
1845
- commands: Command[];
1846
- buttons: Button[];
1847
- };
1848
- details: {
1849
- provider: Provider$1 | 'local';
1850
- user: StreamElements.Event.onWidgetLoad['channel'];
1851
- currency: StreamElements.Event.onWidgetLoad['currency'];
1852
- overlay: StreamElements.Event.onWidgetLoad['overlay'];
1853
- };
1854
- cache: {
1855
- /**
1856
- * Avatar cache duration in minutes.
1857
- */
1858
- avatar: number;
1859
- /**
1860
- * Pronoun cache duration in minutes.
1861
- */
1862
- pronoun: number;
1863
- /**
1864
- * Emote cache duration in minutes.
1865
- */
1866
- emote: number;
1867
- };
1868
- on<K extends keyof ClientEvents>(eventName: K, callback: (this: Client, ...args: ClientEvents[K]) => void): this;
1869
- }
1870
-
1871
- interface ButtonOptions {
1872
- field: string | ((field: string, value: string | boolean | number) => boolean);
1873
- template?: string;
1874
- name?: string;
1875
- value?: string;
1876
- run: (this: Client | undefined, field: string, value: string | boolean | number) => void;
1877
- }
1878
- /**
1879
- * Represents a button action that can be triggered by custom fields in StreamElements.
1880
- * The button can be configured with a template and a name, and it will execute a specified function when triggered.
1881
- * @example
1882
- * ```javascript
1883
- * const button = new Button({
1884
- * field: (field, value) => field.startsWith('message-') && field.split('-')[1],
1885
- * template: 'message-{role}',
1886
- * // name: '[CAP={role}] role message',
1887
- * name: 'Generate {role} message',
1888
- * run(field, value) {
1889
- * console.log(`Button ${field} was clicked with value: ${value}`);
1890
- * }
1891
- * })
1892
- *
1893
- * const field = button.generate([{ role: 'broadcaster' }, { role: 'moderator' }]);
1894
- * // This will create buttons with fields "message-broadcaster" and "message-moderator" and names "Generate broadcaster message" and "Generate moderator message".
1895
- * // field['message-broadcaster'] => { type: 'button', label: 'Generate broadcaster message' }
1896
- * // field['message-moderator'] => { type: 'button', label: 'Generate moderator message' }
1897
- *
1898
- * // When a custom field with the name "message-broadcaster" or "message-moderator" is triggered, the run function will be called with the field and value.
1899
- * ```
1900
- */
1901
- declare class Button {
1902
- field: ButtonOptions['field'];
1903
- template: string;
1904
- name: string;
1905
- value: string;
1906
- run: ButtonOptions['run'];
1907
- constructor(options: ButtonOptions);
1908
- generate(values: Array<Record<string, string | number>>): Record<string, StreamElements.CustomField.Schema>;
1909
- parse(field: string, value: string | boolean | number): Button;
1910
- remove(): void;
1911
- static execute(field: string, value: string | boolean | number): boolean;
2351
+ declare class ElementHelper {
2352
+ /**
2353
+ * Merges outer span styles with inner span styles in the provided HTML string.
2354
+ * @param outerStyle - The style string to be applied to the outer span.
2355
+ * @param innerHTML - The inner HTML string which may contain a span with its own styles.
2356
+ * @returns A new HTML string with merged styles applied to a single span.
2357
+ * @example
2358
+ * ```javascript
2359
+ * const result = mergeSpanStyles("color: red; font-weight: bold;", '<span style="font-size: 14px;">Hello World</span>');
2360
+ * console.log(result); // Output: '<span style="font-size: 14px; color: red; font-weight: bold;">Hello World</span>'
2361
+ * ```
2362
+ */
2363
+ mergeSpanStyles(outerStyle: string, innerHTML: string, className?: string): string;
2364
+ /**
2365
+ * Scales an HTML element to fit within its parent element based on specified minimum and maximum scale factors.
2366
+ * @param element - The HTML element to be scaled.
2367
+ * @param min - Minimum scale factor (default is 0).
2368
+ * @param max - Maximum scale factor (default is 1).
2369
+ * @param options - Optional settings for scaling.
2370
+ * @returns - An object containing the new width, height, and scale factor, or void if not applied.
2371
+ * @example
2372
+ * ```javascript
2373
+ * const element = document.getElementById('myElement');
2374
+ * scale(element, 0.5, 1, { return: false });
2375
+ * ```
2376
+ */
2377
+ scale(element: HTMLElement, min?: number, max?: number, options?: {
2378
+ return: boolean;
2379
+ parent: HTMLElement;
2380
+ base: 'width' | 'height';
2381
+ }): {
2382
+ width: number;
2383
+ height: number;
2384
+ scale: number;
2385
+ } | void;
2386
+ /**
2387
+ * Scales an HTML element to fit within its parent element based on specified options.
2388
+ * @param element - The HTML element to be scaled.
2389
+ * @param options - Optional settings for scaling.
2390
+ * @returns The scale factor applied to the element.
2391
+ * @example
2392
+ * ```javascript
2393
+ * const element = document.getElementById('myElement');
2394
+ * const scaleFactor scalev2(element, {
2395
+ * min: 0.5,
2396
+ * max: 1,
2397
+ * prefer: 'width',
2398
+ * apply: (scale, el) => el.style.transform = `scale(${scale})`
2399
+ * });
2400
+ * console.log(`Element scaled by a factor of ${scaleFactor}`);
2401
+ * ```
2402
+ */
2403
+ scalev2<T extends HTMLElement>(element: T, options?: ScaleOptions<T>): number;
2404
+ /**
2405
+ * Fits the text within the parent element by adjusting the font size.
2406
+ * @param element - The HTML element containing the text to be fitted.
2407
+ * @param compressor - A multiplier to adjust the fitting sensitivity (default is 1).
2408
+ * @param options - Optional settings for fitting text.
2409
+ * @returns The HTML element with adjusted font size.
2410
+ * @example
2411
+ * ```javascript
2412
+ * const element = document.getElementById('myTextElement');
2413
+ * fitText(element, 1, { minFontSize: 12, maxFontSize: 36 });
2414
+ * console.log(`Adjusted font size: ${element.style.fontSize}`);
2415
+ * ```
2416
+ */
2417
+ fitText(element: HTMLElement, compressor?: number, options?: FitTextOptions): HTMLElement;
2418
+ /**
2419
+ * Wraps formatted HTML text with containers and splits characters into indexed spans.
2420
+ * Adds 'container' class and data-index to all parent elements, and wraps each character in a span with class 'char' and data-index.
2421
+ * @param htmlString - The input HTML string containing formatted text elements (span, strong, em, etc).
2422
+ * @param startIndex - The starting index for the data-index attribute (default is 0).
2423
+ * @returns - A new HTML string with containers and character-level indexing.
2424
+ * @example
2425
+ * ```javascript
2426
+ * const result = splitTextToChars('<span>TesTe</span> <strong>bold</strong>', 0);
2427
+ * console.log(result);
2428
+ * // Output: '<span class="container" data-index="0"><span class="char" data-index="0">T</span><span class="char" data-index="1">e</span>...'
2429
+ * ```
2430
+ */
2431
+ splitTextToChars(htmlString: string, startIndex?: number, preserveInterElementWhitespace?: boolean): string;
1912
2432
  }
1913
2433
 
1914
- interface Theme {
1915
- color?: string;
1916
- background?: string;
1917
- bold?: boolean;
1918
- italic?: boolean;
1919
- fontSize?: number;
1920
- icon?: string;
1921
- }
1922
- interface Options {
1923
- enabled?: boolean;
1924
- prefix?: string | (() => string);
1925
- }
1926
- type LogMethod = (...args: unknown[]) => void;
1927
- declare class useLogger {
1928
- enabled: boolean;
1929
- prefix: string | (() => string);
1930
- constructor(options?: Options);
1931
- apply(theme: Theme): LogMethod;
1932
- private style;
1933
- group(label: string): void;
1934
- groupCollapsed(label: string): void;
1935
- groupEnd(): void;
1936
- table(data: unknown): void;
1937
- time(label: string): void;
1938
- timeEnd(label: string): void;
1939
- readonly error: LogMethod;
1940
- readonly warn: LogMethod;
1941
- readonly success: LogMethod;
1942
- readonly info: LogMethod;
1943
- readonly debug: LogMethod;
1944
- readonly alert: LogMethod;
1945
- readonly status: LogMethod;
1946
- readonly received: LogMethod;
1947
- readonly simple: LogMethod;
2434
+ declare class ObjectHelper {
2435
+ /**
2436
+ * Flattens a nested object into a single-level object with dot-separated keys.
2437
+ * @param obj - The nested object to be flattened.
2438
+ * @param prefix - The prefix to be added to each key (used for recursion).
2439
+ * @returns A flattened object with dot-separated keys.
2440
+ * @example
2441
+ * ```javascript
2442
+ * const nestedObj = { a: { b: 1, c: { d: 2 } }, e: [3, 4] };
2443
+ * const flatObj = flatten(nestedObj);
2444
+ * console.log(flatObj);
2445
+ * // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' }
2446
+ * ```
2447
+ */
2448
+ flatten(obj: Record<string, any>, stringify?: boolean, prefix?: string): Record<string, typeof stringify extends true ? string : string | number | boolean>;
2449
+ /**
2450
+ * Returns the entries of an object as an array of key-value pairs, with proper typing.
2451
+ * @param obj - The object to retrieve entries from.
2452
+ * @returns An array of key-value pairs from the object, typed as an array of tuples with key and value types.
2453
+ */
2454
+ entries<K extends string, V>(obj: Record<K, V>): [K, V][];
2455
+ /**
2456
+ * Returns the values of an object as an array, with proper typing.
2457
+ * @param obj - The object to retrieve values from.
2458
+ * @returns An array of values from the object, typed as an array of the value type.
2459
+ */
2460
+ values<K extends string, V>(obj: Record<K, V>): V[];
2461
+ /**
2462
+ * Returns the keys of an object as an array of strings, with proper typing.
2463
+ * @param obj - The object to retrieve keys from.
2464
+ * @returns An array of keys from the object, typed as an array of strings.
2465
+ */
2466
+ keys<K extends string, V>(obj: Record<K, V>): K[];
1948
2467
  }
1949
2468
 
1950
- type QueueEvents<T> = {
1951
- load: [];
1952
- cancel: [];
1953
- update: [
1954
- queue: QueueItem<T>[],
1955
- priorityQueue: QueueItem<T>[],
1956
- history: QueueItem<T>[],
1957
- timeouts: Array<ReturnType<typeof setTimeout>>
1958
- ];
1959
- process: [item: QueueItem<T>, queue: useQueue<T>];
2469
+ type BadgeOptions = Twitch.tags[] | Twitch.tags | `${Twitch.tags}/${string}` | `${Twitch.tags}/${string}`[];
2470
+ type TwitchResult = {
2471
+ keys: Twitch.tags[];
2472
+ badges: Twitch.badge[];
2473
+ versions: {
2474
+ [K in Twitch.tags]?: string | number;
2475
+ };
2476
+ amount: {
2477
+ [K in Twitch.tags]?: string | number;
2478
+ };
1960
2479
  };
1961
- type QueueProps = {
1962
- isoDate: string;
1963
- isLoop: boolean;
1964
- isPriority: boolean;
1965
- isImmediate: boolean;
2480
+ type YouTubeResult = {
2481
+ isVerified: boolean;
2482
+ isChatOwner: boolean;
2483
+ isChatSponsor: boolean;
2484
+ isChatModerator: boolean;
1966
2485
  };
1967
- type QueueItem<T> = {
1968
- value: T;
1969
- } & QueueProps;
1970
- type QueueProcessor<T> = (this: useQueue<T>, item: T, queue: useQueue<T>) => Promise<any>;
1971
- type QueueDuration = number | boolean | undefined;
1972
- interface QueueOptions<T> {
2486
+ declare class MessageHelper {
1973
2487
  /**
1974
- * Duration between processing each item in milliseconds. Set to `0` or `false` for immediate processing.
2488
+ * Finds emotes in a given text.
2489
+ * @param text - The text to search for emotes.
2490
+ * @param emotes - An array of emotes to search for. Defaults to Local data emotes.
2491
+ * @returns An array of emotes found in the text with their positions.
1975
2492
  */
1976
- duration?: QueueDuration | 'client';
2493
+ findEmotesInText(text: string, emotes?: Emote[]): Emote[];
1977
2494
  /**
1978
- * Function to process each item in the queue.
2495
+ * Replaces emotes in the text with corresponding HTML image tags.
2496
+ * @param text - The text containing emotes.
2497
+ * @param emotes - An array of emotes with their positions in the text.
2498
+ * @returns The text with emotes replaced by HTML image tags.
1979
2499
  */
1980
- processor: QueueProcessor<T>;
2500
+ replaceEmotesWithHTML(text: string, emotes: Emote[]): string;
2501
+ /**
2502
+ * Checks if the text contains only emotes and whitespace.
2503
+ * @param text - The text to check.
2504
+ * @param emotes - An array of emotes with their positions in the text.
2505
+ * @returns True if the text contains only emotes and whitespace, false otherwise.
2506
+ */
2507
+ hasOnlyEmotes(text: string, emotes: Emote[]): boolean;
2508
+ /**
2509
+ * Replaces YouTube emotes in the text with corresponding HTML image tags.
2510
+ * @param text - The text containing YouTube emotes.
2511
+ * @param emotes - An array of YouTube emotes. Defaults to Local data YouTube emotes.
2512
+ * @returns The text with YouTube emotes replaced by HTML image tags.
2513
+ */
2514
+ replaceYoutubeEmotesWithHTML(text: string, emotes?: {
2515
+ emojiId: string;
2516
+ shortcuts: string[];
2517
+ searchTerms: string[];
2518
+ image: {
2519
+ thumbnails: {
2520
+ url: string;
2521
+ width: number;
2522
+ height: number;
2523
+ }[];
2524
+ accessibility: {
2525
+ accessibilityData: {
2526
+ label: string;
2527
+ };
2528
+ };
2529
+ };
2530
+ isCustomEmoji: boolean;
2531
+ index: number;
2532
+ }[]): string;
2533
+ /**
2534
+ * Maps global badge versions to a structured format.
2535
+ * @param globalBadges - An array of Twitch global badges. Defaults to Local data badges.
2536
+ * @returns An array of objects containing badge IDs and their corresponding versions.
2537
+ * @example
2538
+ * ```javascript
2539
+ * const badgeVersions = mapGlobalBadgeVersions();
2540
+ * console.log(badgeVersions);
2541
+ * // Output:
2542
+ * [
2543
+ * {
2544
+ * id: 'subscriber',
2545
+ * versions: [
2546
+ * { type: 'subscriber', version: '1', url: 'https://...', description: 'Subscriber' },
2547
+ * { type: 'subscriber', version: '2', url: 'https://...', description: '2-Month Subscriber' },
2548
+ * // ... more versions
2549
+ * ],
2550
+ * },
2551
+ * {
2552
+ * id: 'bits',
2553
+ * versions: [
2554
+ * { type: 'bits', version: '100', url: 'https://...', description: 'cheer 100' },
2555
+ * { type: 'bits', version: '1000', url: 'https://...', description: 'cheer 1000' },
2556
+ * // ... more versions
2557
+ * ],
2558
+ * },
2559
+ * // ... more badges
2560
+ * ]
2561
+ * ```
2562
+ */
2563
+ mapGlobalBadgeVersions(globalBadges?: Twitch.GlobalBadge[]): Array<{
2564
+ id: Twitch.tags;
2565
+ versions: Twitch.badge[];
2566
+ }>;
2567
+ /**
2568
+ * Maps a badge type and variation to the corresponding badge version amount.
2569
+ * @param type - The badge type (e.g., 'subscriber', 'bits', etc.).
2570
+ * @param variation - The badge variation, which can be a number or a string (e.g., 'horde', 'alliance', etc.).
2571
+ * @returns The badge version amount as a string. Returns '0' if no matching badge version is found.
2572
+ * @example
2573
+ * ```javascript
2574
+ * // For subscriber badge with 3 months
2575
+ * mapGlobalBadgeVersionAmount('subscriber', 3); // Returns '3'
2576
+ * // For bits badge with 5000 bits
2577
+ * mapGlobalBadgeVersionAmount('bits', 5000); // Returns the corresponding badge version based on the mapping
2578
+ * // For warcraft badge with 'horde' variation
2579
+ * mapGlobalBadgeVersionAmount('warcraft', 'horde'); // Returns 'horde'
2580
+ * ```
2581
+ */
2582
+ mapGlobalBadgeVersionAmount(type: Twitch.tags, variation: string | number): string;
2583
+ /**
2584
+ * Generates badge data based on the provided badges and platform.
2585
+ * @param badges - The badges to generate. Can be an array or a comma-separated string.
2586
+ * @param provider - The platform provider ('twitch' or 'youtube'). Defaults to 'twitch'.
2587
+ * @returns A promise that resolves to the generated badge data.
2588
+ * @example
2589
+ * ```javascript
2590
+ * // Generate Twitch badges
2591
+ * const twitchBadges = await generateBadges(['broadcaster', 'moderator'], 'twitch');
2592
+ * // Generate YouTube badges
2593
+ * const youtubeBadges = await generateBadges('sponsor, moderator', 'youtube');
2594
+ * ```
2595
+ */
2596
+ generateBadges<T extends Provider$1>(badges: BadgeOptions | undefined, provider: T): Promise<T extends 'twitch' ? TwitchResult : YouTubeResult>;
1981
2597
  }
1982
- /**
1983
- * A utility class to manage a queue of items with support for priority, looping, and immediate processing.
1984
- * @template T - The type of items in the queue.
1985
- * @extends EventProvider<QueueEvents<T>>
1986
- * @example
1987
- * ```javascript
1988
- * const myQueue = new useQueue({
1989
- * duration: 1000,
1990
- * processor: async function (item) {
1991
- * console.log('Processing item:', item);
1992
- * },
1993
- * });
1994
- *
1995
- * myQueue.enqueue('Item 1');
1996
- * myQueue.enqueue('Item 2', { isPriority: true });
1997
- * ```
1998
- */
1999
- declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
2000
- queue: QueueItem<T>[];
2001
- priorityQueue: QueueItem<T>[];
2002
- history: QueueItem<T>[];
2003
- private timeouts;
2004
- running: boolean;
2005
- duration: QueueDuration;
2006
- private loaded;
2007
- processor: QueueProcessor<T>;
2008
- private readonly clientWaitRetryDelay;
2009
- constructor(options: QueueOptions<T>);
2010
- private waitForClientAndBindLoad;
2598
+
2599
+ declare class RandomHelper {
2011
2600
  /**
2012
- * Enqueue an item or multiple items into the queue with optional processing options.
2013
- * @param value - The item or items to be enqueued. Can be a single value of type T or an array of objects containing the value and options.
2014
- * @param options - Optional processing options for the item(s) being enqueued. Ignored if an array of items is provided, as each item can have its own options.
2015
- * @returns The instance of the queue for chaining.
2601
+ * Generate random color
2602
+ * @param type - Color format
2603
+ * @returns - Random color in specified format
2016
2604
  * @example
2017
2605
  * ```javascript
2018
- * myQueue.enqueue('Single Item', { isPriority: true });
2019
- * myQueue.enqueue([
2020
- * { value: 'Item 1', options: { isPriority: true } },
2021
- * { value: 'Item 2', options: { isLoop: true } }
2022
- * ]);
2606
+ * const hexColor = random.color('hex');
2607
+ * console.log(hexColor); // e.g. #3e92cc
2608
+ *
2609
+ * const rgbColor = random.color('rgb');
2610
+ * console.log(rgbColor); // e.g. rgb(62, 146, 204)
2023
2611
  * ```
2024
2612
  */
2025
- enqueue(value: T, options?: Partial<QueueProps>): this;
2026
- enqueue(items: {
2027
- value: T;
2028
- options?: Partial<QueueProps>;
2029
- }[]): this;
2030
- private run;
2031
- private next;
2613
+ color(type?: 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): string;
2032
2614
  /**
2033
- * Resume processing the queue if it is paused. If the queue is already running, it will be restarted, which can be useful if new items have been added or if you want to reset the processing timer.
2034
- * If the queue was empty before, it will start processing immediately.
2035
- * @returns - The instance of the queue for chaining.
2615
+ * Generate random number
2616
+ * @param min - Minimum value
2617
+ * @param max - Maximum value
2618
+ * @param float - Number of decimal places (0 for integer)
2619
+ * @returns - Random number
2036
2620
  * @example
2037
2621
  * ```javascript
2038
- * myQueue.resume();
2622
+ * const intNumber = random.number(1, 10);
2623
+ * console.log(intNumber); // e.g. 7
2624
+ *
2625
+ * const floatNumber = random.number(1, 10, 2);
2626
+ * console.log(floatNumber); // e.g. 3.14
2039
2627
  * ```
2040
2628
  */
2041
- resume(): this;
2629
+ number(min: number, max: number, float?: number): number;
2042
2630
  /**
2043
- * Update the queue's state with new values. This can be used to replace the current queue, priority queue, history, or timeouts with new data. If the queue is not currently running and there are items in the queue after the update, it will start processing immediately.
2044
- * @param save - An object containing the new state for the queue, priority queue, history, and timeouts. Each property is optional, and if not provided, the current state will be retained.
2045
- * @returns - The instance of the queue for chaining.
2631
+ * Generate random boolean
2632
+ * @param threshold - Threshold between 0 and 1
2633
+ * @returns - Random boolean
2046
2634
  * @example
2047
2635
  * ```javascript
2048
- * myQueue.update({
2049
- * queue: newQueueItems,
2050
- * priorityQueue: newPriorityItems,
2051
- * history: newHistory,
2636
+ * const boolValue = random.boolean(0.7);
2637
+ * console.log(boolValue); // e.g. true (70% chance)
2638
+ * ```
2639
+ */
2640
+ boolean(threshold?: number): boolean;
2641
+ /**
2642
+ * Generate random string
2643
+ * @param length - Length of the string
2644
+ * @param chars - Characters to use
2645
+ * @returns - Random string
2646
+ * @example
2647
+ * ```javascript
2648
+ * const randString = random.string(10); // e.g. "aZ3bT9qP1x"
2649
+ * const randHex = random.string(8, 'hex'); // e.g. "4f3c2a1b"
2650
+ * const randNumStr = random.string(6, 'numbers'); // e.g. "839201"
2651
+ * const randLetterStr = random.string(6, 'letters'); // e.g. "aZbTqP"
2652
+ * const randHexUpper = random.string(6, 'hex-upper'); // e.g. "4F3C2A1B"
2653
+ * const randHexLower = random.string(6, 'hex-lower'); // e.g. "4f3c2a1b"
2654
+ * ```
2655
+ */
2656
+ string(length: number, chars?: 'numeric' | 'numbers' | 'letters' | 'hex' | 'hex-upper' | 'hex-lower' | string): string;
2657
+ /**
2658
+ * Pick random element from array
2659
+ * @param arr - Array to pick from
2660
+ * @returns - Random element and its index
2661
+ * @example
2662
+ * ```javascript
2663
+ * const [element, index] = random.array(['apple', 'banana', 'cherry']);
2664
+ * console.log(element, index); // e.g. "banana", 1
2665
+ * ```
2666
+ */
2667
+ array<T>(arr: T[]): [value: T, index: number];
2668
+ /**
2669
+ * Generate random date
2670
+ * @param start - Start date
2671
+ * @param end - End date
2672
+ * @returns - Random date between start and end
2673
+ * @example
2674
+ * ```javascript
2675
+ * const randDate = random.date(new Date(2020, 0, 1), new Date());
2676
+ * console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z
2677
+ * ```
2678
+ */
2679
+ date(start?: Date, end?: Date): Date;
2680
+ /**
2681
+ * Generate ISO date string offset by days
2682
+ * @param daysAgo - Number of days to go back
2683
+ * @returns - ISO date string
2684
+ * @example
2685
+ * ```javascript
2686
+ * const isoDate = random.daysOffset(7);
2687
+ * console.log(isoDate); // e.g. "2024-06-10T14:23:45.678Z"
2688
+ *
2689
+ * const isoDate30 = random.daysOffset(30);
2690
+ * console.log(isoDate30); // e.g. "2024-05-18T09:15:30.123Z"
2691
+ * ```
2692
+ */
2693
+ daysOffset(daysAgo: number): string;
2694
+ /**
2695
+ * Generate UUID v4
2696
+ * @returns - UUID string
2697
+ * @example
2698
+ * ```javascript
2699
+ * const uuid = random.uuid();
2700
+ * console.log(uuid); // e.g. "3b12f1df-5232-4e3a-9a0c-3f9f1b1b1b1b"
2701
+ * ```
2702
+ */
2703
+ uuid(): string;
2704
+ }
2705
+
2706
+ declare class EventHelper {
2707
+ /**
2708
+ * Parses the provider information from the event detail object.
2709
+ * @param detail - The event detail object received from the StreamElements event.
2710
+ * @returns An object containing the provider and the original event data.
2711
+ */
2712
+ parseProvider(detail: StreamElements.Event.onEventReceived, _provider?: Provider$1): ClientEvents$1;
2713
+ }
2714
+
2715
+ type Modifier = (value: string, param: string | null | undefined, values: {
2716
+ amount?: number;
2717
+ count?: number;
2718
+ }) => string;
2719
+ declare class StringHelper {
2720
+ /**
2721
+ * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
2722
+ * @param string - The input string to perform replacements on.
2723
+ * @param pattern - The pattern to match in the string (can be a string or a regular expression).
2724
+ * @param callback - An asynchronous callback function that takes the matched substring and any captured groups as arguments and returns the replacement string.
2725
+ * @returns A promise that resolves to the modified string with replacements applied.
2726
+ * @example
2727
+ * ```javascript
2728
+ * const result = await string.replace("Hello World", /World/, async (match) => {
2729
+ * return await fetchSomeData(match); // Assume this function fetches data asynchronously
2052
2730
  * });
2731
+ * console.log(result); // Output will depend on the fetched data
2053
2732
  * ```
2054
2733
  */
2055
- update(save: Partial<useQueue<T>>): this;
2734
+ replace(string: string, pattern: string, callback: (match: string, ...groups: string[]) => Promise<string> | string): Promise<string>;
2056
2735
  /**
2057
- * Cancel all pending timeouts and stop the queue from processing further items. This will clear any scheduled processing and prevent any new items from being processed until `resume()` is called again. The current state of the queue, priority queue, and history will be retained, allowing you to resume processing later without losing any data.
2736
+ * Capitalizes the first letter of a given string.
2737
+ * @param string - The input string to be capitalized.
2738
+ * @returns The capitalized string.
2739
+ * @example
2740
+ * ```javascript
2741
+ * const result = string.capitalize("hello world");
2742
+ * console.log(result); // Output: "Hello world"
2743
+ * ```
2058
2744
  */
2059
- cancel(): void;
2745
+ capitalize(string: string): Capitalize<string>;
2746
+ PRESETS: Record<string, string>;
2060
2747
  /**
2061
- * Check if there are any items in the queue or priority queue. This method returns `true` if there are items waiting to be processed in either the main queue or the priority queue, and `false` if both queues are empty.
2062
- * @returns - A boolean indicating whether there are items in the queue or priority queue.
2748
+ * Composes a template string by replacing placeholders with corresponding values and applying optional modifiers.
2749
+ * @param template - The template string containing placeholders in the format {key} and optional modifiers in the format [MODIFIER:param=value].
2750
+ * @param values - An object containing key-value pairs to replace the placeholders in the template.
2751
+ * @param options - Optional settings for the composition process.
2752
+ * @returns The composed string with placeholders replaced and modifiers applied.
2753
+ * @example
2754
+ * ```javascript
2755
+ * const { string } = Tixyel.Helper;
2756
+ *
2757
+ * // Basic usage with placeholders and simple modifiers
2758
+ * const template1 = "Hello, {username}! You have {amount} [UPC=messages] and your name is [CAP=name].";
2759
+ * const values1 = { username: "john_doe", amount: 5, name: "john" };
2760
+ * const result1 = string.compose(template1, values1);
2761
+ * // "Hello, john_doe! You have 5 MESSAGES and your name is John."
2762
+ *
2763
+ * // Multiple modifiers in a single block (HTML enabled)
2764
+ * const template2 = "[COLOR:#ff0056,BOLD={username}]";
2765
+ * const values2 = { username: "john_doe" };
2766
+ * const result2 = string.compose(template2, values2, { html: true });
2767
+ * // '<span class="color bold" style="color: #ff0056; font-weight: bold;">john_doe</span>'
2768
+ *
2769
+ * // Conditional rendering with IF (supports ===, >=, &&, ||, !, etc.)
2770
+ * const template3 = "[IF=vip && status === 'live'?VIP Online|Offline]";
2771
+ * const values3 = { status: 'live', vip: true };
2772
+ * const result3 = string.compose(template3, values3);
2773
+ * // "VIP Online"
2774
+ *
2775
+ * // Pluralization using amount / count or an explicit key
2776
+ * const template4 = "You have {amount} [PLURAL=message|messages].";
2777
+ * const values4 = { amount: 1 };
2778
+ * const values5 = { amount: 3 };
2779
+ * const result4a = string.compose(template4, values4); // "You have 1 message."
2780
+ * const result4b = string.compose(template4, values5); // "You have 3 messages."
2781
+ *
2782
+ * // Number formatting
2783
+ * const template5 = "Total: [NUMBER:2=amount] {currency}";
2784
+ * const values6 = { amount: 1234.5, currency: '$' };
2785
+ * const result5 = string.compose(template5, values6);
2786
+ * // e.g. "Total: 1,234.50 $" (locale dependent)
2787
+ *
2788
+ * // Date and time formatting
2789
+ * const template6 = "Created at: [DATE:iso=createdAt] ([DATE:relative=createdAt])";
2790
+ * const values7 = { createdAt: new Date('2020-01-02T03:04:05.000Z') };
2791
+ * const result6 = string.compose(template6, values7);
2792
+ * // e.g. "Created at: 2020-01-02T03:04:05.000Z (Xs ago)"
2793
+ *
2794
+ * // MAP / SWITCH style mapping
2795
+ * const template7 = "Status: [MAP:status=live:Online|offline:Offline|default:Unknown]";
2796
+ * const values8 = { status: 'offline' };
2797
+ * const result7 = string.compose(template7, values8);
2798
+ * // "Status: Offline"
2799
+ *
2800
+ * // Escaping HTML
2801
+ * const template8 = "[ESCAPE={message}]";
2802
+ * const values9 = { message: '<b>Danger & "HTML"</b>' };
2803
+ * const result8 = string.compose(template8, values9);
2804
+ * // "&lt;b&gt;Danger &amp; &quot;HTML&quot;&lt;/b&gt;"
2805
+ *
2806
+ * // Using global presets
2807
+ * Helper.string.PRESETS['alert'] = 'BOLD,COLOR:#ff0056';
2808
+ * const template10 = "[PRESET:alert={username}]";
2809
+ * const values11 = { username: 'john_doe' };
2810
+ * const result10 = string.compose(template10, values11, { html: true });
2811
+ * // '<span class="color bold" style="color: #ff0056; font-weight: bold;">john_doe</span>'
2812
+ * ```
2063
2813
  */
2064
- hasItems(): boolean;
2065
- on<K extends keyof QueueEvents<T>>(eventName: K, callback: (this: useQueue<T>, ...args: QueueEvents<T>[K]) => void): this;
2814
+ compose(template: string, values?: Record<string, any>, options?: {
2815
+ method?: 'loop' | 'index';
2816
+ html?: boolean;
2817
+ debug?: boolean;
2818
+ modifiers?: Record<string, Modifier>;
2819
+ aliases?: Record<string, string[]>;
2820
+ }): string;
2066
2821
  }
2067
2822
 
2068
- type ComfyEvents = {
2069
- load: [instance: ComfyJSInstance];
2070
- error: Parameters<OnErrorHandler>;
2071
- command: Parameters<OnCommandHandler>;
2072
- chat: Parameters<OnChatHandler>;
2073
- whisper: Parameters<OnWhisperHandler>;
2074
- messageDeleted: Parameters<OnMessageDeletedHandler>;
2075
- join: Parameters<OnJoinHandler>;
2076
- part: Parameters<OnPartHandler>;
2077
- hosted: Parameters<OnHostedHandler>;
2078
- raid: Parameters<OnRaidHandler>;
2079
- sub: Parameters<OnSubHandler>;
2080
- resub: Parameters<OnResubHandler>;
2081
- subGift: Parameters<OnSubGiftHandler>;
2082
- subMysteryGift: Parameters<OnSubMysteryGiftHandler>;
2083
- giftSubContinue: Parameters<OnGiftSubContinueHandler>;
2084
- cheer: Parameters<OnCheerHandler>;
2085
- chatMode: Parameters<OnChatModeHandler>;
2086
- reward: Parameters<OnRewardHandler>;
2087
- connected: Parameters<OnConnectedHandler>;
2088
- reconnect: Parameters<OnReconnectHandler>;
2089
- };
2090
- /**
2091
- * Creates and manages a ComfyJS instance for Twitch chat interaction.
2092
- */
2093
- declare class useComfyJs extends EventProvider<ComfyEvents> {
2094
- instance: ComfyJSInstance;
2095
- username: string;
2096
- password?: string;
2097
- channels: string[];
2098
- isDebug: boolean;
2099
- private init;
2100
- emulate: boolean;
2823
+ declare class ColorHelper {
2101
2824
  /**
2102
- * Initializes a new ComfyJS instance and connects to Twitch chat.
2103
- * @param options - Configuration options for ComfyJS instance.
2104
- * @param emulate - Whether to emulate chat messages in the Local module.
2825
+ * Generate opacity hex value
2826
+ * @param opacity - Opacity value from 0 to 100
2827
+ * @param color - Hex color code
2828
+ * @returns - Hex color code with opacity
2105
2829
  */
2106
- constructor(options: {
2107
- username: string;
2108
- password?: string;
2109
- channels: string[];
2110
- isDebug?: boolean;
2111
- init?: boolean;
2112
- }, emulate: boolean);
2830
+ opacity(opacity?: number, color?: string): string;
2831
+ /**
2832
+ * Extract color and opacity from hex code
2833
+ * @param hex - Hex color code
2834
+ * @returns - Object with color and opacity
2835
+ */
2836
+ extract(hex: string): {
2837
+ color: string;
2838
+ opacity: number;
2839
+ };
2840
+ /**
2841
+ * Validate color string format
2842
+ * @param str - Color string to validate
2843
+ * @returns Detected color format or false if invalid
2844
+ * @example
2845
+ * ```javascript
2846
+ * const format1 = color.validate("#FF5733"); // "hex"
2847
+ * const format2 = color.validate("rgb(255, 87, 51)"); // "rgb"
2848
+ * const format3 = color.validate("hsl(14, 100%, 60%)"); // "hsl"
2849
+ * const format4 = color.validate("orangered"); // "css-color-name"
2850
+ * const format5 = color.validate("invalid-color"); // false
2851
+ * ```
2852
+ */
2853
+ validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name";
2854
+ /**
2855
+ * Convert color to different format
2856
+ * @param str - Color string to convert (e.g. "#FF5733", "rgb(255, 87, 51)")
2857
+ * @param format - Target format
2858
+ * @returns - Converted color string
2859
+ * @example
2860
+ * ```javascript
2861
+ * const hexColor = color.convert("rgb(255, 87, 51)", "hex"); // "#FF5733"
2862
+ * const rgbColor = color.convert("#FF5733", "rgb"); // "rgb(255, 87, 51)"
2863
+ * const hslColor = color.convert("#FF5733", "hsl"); // "hsl(14, 100%, 60%)"
2864
+ * const colorName = color.convert("#FF5733", "css-color-name"); // "orangered"
2865
+ * ```
2866
+ */
2867
+ convert(str: string, format: 'hex' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): Promise<string | null>;
2868
+ }
2869
+
2870
+ declare class SoundHelper {
2871
+ playing: boolean;
2872
+ audio: AudioContext;
2873
+ /**
2874
+ * Play sound from URL with optional volume and replace parameters
2875
+ * @param url - Sound URL to play
2876
+ * @param volume - Volume level from 0 to 100 (default: 100)
2877
+ * @param replace - If true, replaces currently playing sound (default: false)
2878
+ */
2879
+ play(url: string, volume?: number, replace?: boolean): void;
2880
+ }
2881
+
2882
+ declare class FunctionHelper {
2883
+ /**
2884
+ * Apply function with given thisArg and arguments
2885
+ * @param fn - Function to apply
2886
+ * @param thisArg - Value to use as this when calling fn
2887
+ * @param args - Arguments to pass to fn
2888
+ * @returns Result of calling fn with thisArg and args
2889
+ */
2890
+ apply<TThis, TArgs extends unknown[], TReturn>(fn: (this: TThis, ...args: TArgs) => TReturn, thisArg: TThis, args: TArgs): TReturn;
2891
+ /**
2892
+ * Call function with given thisArg and arguments
2893
+ * @param fn - Function to call
2894
+ * @param thisArg - Value to use as this when calling fn
2895
+ * @param args - Arguments to pass to fn
2896
+ * @returns Result of calling fn with thisArg and args
2897
+ */
2898
+ call<TThis, TArgs extends unknown[], TReturn>(fn: (this: TThis, ...args: TArgs) => TReturn, thisArg: TThis, ...args: TArgs): TReturn;
2899
+ }
2900
+
2901
+ declare class UtilsHelper {
2902
+ /**
2903
+ * Delays execution for a specified number of milliseconds.
2904
+ * @param ms - The number of milliseconds to delay.
2905
+ * @returns A Promise that resolves after the specified delay.
2906
+ */
2907
+ delay<R extends any, M extends number>(ms: M, callback?: () => R): Promise<R | null>;
2908
+ /**
2909
+ * Returns typed entries of an object.
2910
+ * @param obj - The object to get entries from.
2911
+ * @returns An array of key-value pairs from the object.
2912
+ */
2913
+ typedEntries<K extends string, V>(obj: Record<K, V> | Array<V>): [K, V][];
2914
+ /**
2915
+ * Returns typed values of an object.
2916
+ * @param obj - The object to get values from.
2917
+ * @returns An array of values from the object.
2918
+ */
2919
+ typedValues<K extends string, V>(obj: Record<K, V> | Array<V>): V[];
2920
+ /**
2921
+ * Returns typed keys of an object.
2922
+ * @param obj - The object to get keys from.
2923
+ * @returns An array of keys from the object.
2924
+ */
2925
+ typedKeys<K extends string, V>(obj: Record<K, V> | Array<V>): K[];
2926
+ /**
2927
+ * Compares two dates and returns the difference in multiple time units.
2928
+ *
2929
+ * `total` values are based on raw milliseconds (can be decimal).
2930
+ * `calendar` values use calendar boundaries for full months/years.
2931
+ */
2932
+ compareDates(date1: Date | string, date2: Date | string): {
2933
+ milliseconds: number;
2934
+ seconds: number;
2935
+ minutes: number;
2936
+ hours: number;
2937
+ days: number;
2938
+ months: number;
2939
+ years: number;
2940
+ absolute: {
2941
+ milliseconds: number;
2942
+ seconds: number;
2943
+ minutes: number;
2944
+ hours: number;
2945
+ days: number;
2946
+ months: number;
2947
+ years: number;
2948
+ };
2949
+ calendar: {
2950
+ months: number;
2951
+ years: number;
2952
+ };
2953
+ isFuture: boolean;
2954
+ isPast: boolean;
2955
+ isSameMoment: boolean;
2956
+ };
2957
+ /**
2958
+ * Selects an item based on weighted probabilities.
2959
+ * @param items - An object where keys are items and values are their weights.
2960
+ * @returns A randomly selected item based on the given probabilities.
2961
+ * @example
2962
+ * ```ts
2963
+ * const utils = new UtilsHelper();
2964
+ * const result = utils.probability({
2965
+ * apple: 0.5,
2966
+ * banana: 0.3,
2967
+ * cherry: 0.2,
2968
+ * });
2969
+ * console.log(result); // 'apple', 'banana', or 'cherry' based on the defined probabilities
2970
+ * ```
2971
+ */
2972
+ probability<K extends string, V extends number>(items: Record<K, V>): K | undefined;
2113
2973
  /**
2114
- * Loads the ComfyJS script if not already loaded.
2115
- * @returns A promise that resolves to the ComfyJS instance.
2974
+ * Finds the subscription tier of a user based on various sources of information.
2975
+ * @param data - An object containing userId, name, and broadcasterId to identify the user.
2976
+ * @param session - The current session data which may contain recent subscription information.
2977
+ * @param checkWithAPI - Whether to check the subscription tier with an external API as a last resort.
2978
+ * @returns A promise that resolves to the subscription tier of the user (1, 2, or 3).
2979
+ * @example
2980
+ * ```javascript
2981
+ * const utils = new UtilsHelper();
2982
+ * const tier = await utils.findSubscriptionTier(
2983
+ * { userId: '12345', name: 'exampleUser', broadcasterId: '67890' },
2984
+ * sessionData,
2985
+ * true
2986
+ * );
2987
+ * console.log(tier); // 1, 2, or 3 based on the user's subscription tier
2988
+ * ```
2116
2989
  */
2117
- private load;
2990
+ findSubscriptionTier({ userId, name, broadcasterId, }: {
2991
+ userId: string;
2992
+ name: string;
2993
+ broadcasterId?: string;
2994
+ }, session: StreamElements.Session.Data, checkWithAPI?: boolean): Promise<1 | 2 | 3>;
2118
2995
  /**
2119
- * Connects event handlers to the ComfyJS instance.
2996
+ * Identifies a user based on the received event and session data, returning their ID, name, role, badges, and top status.
2997
+ * @param receivedEvent - The event received from the provider (Twitch or YouTube) containing user information.
2998
+ * @param session - The current session data which may contain recent activity and top user information.
2999
+ * @returns A promise that resolves to an object containing the user's ID, name, role, badges, and top status, or undefined if the user cannot be identified.
3000
+ * @example
3001
+ * ```javascript
3002
+ * const utils = new UtilsHelper();
3003
+ * const userInfo = await utils.identifyUser(receivedEvent, sessionData);
3004
+ * console.log(userInfo);
3005
+ * // {
3006
+ * // id: '12345',
3007
+ * // name: 'exampleUser',
3008
+ * // role: 'moderator',
3009
+ * // badges: [{ type: 'moderator', version: '1', url: 'https:...', description: 'Moderator' }],
3010
+ * // top: {
3011
+ * // gifter: false,
3012
+ * // tip: {
3013
+ * // session: { donator: false, donation: false },
3014
+ * // weekly: { donator: false, donation: false },
3015
+ * // monthly: { donator: false, donation: false },
3016
+ * // alltime: { donator: false, donation: false },
3017
+ * // },
3018
+ * // ...
3019
+ * // }
3020
+ * // }
3021
+ * ```
2120
3022
  */
2121
- private connect;
3023
+ identifyUser(receivedEvent: StreamElements.Event.Provider.Twitch.Message | StreamElements.Event.Provider.YouTube.Message, session: StreamElements.Session.Data): Promise<IdentifyYouTubeResult | IdentifyTwitchResult | undefined>;
2122
3024
  }
2123
-
2124
- declare namespace Helper {
2125
- namespace number {
2126
- /**
2127
- * Translate number to words
2128
- * @param num - Number to translate
2129
- * @param type - Translation type
2130
- * @returns - Number in words
2131
- * @example
2132
- * ```javascript
2133
- * const cardinal = Simulation.number.translate(42, 'cardinal');
2134
- * console.log(cardinal); // "forty-two"
2135
- * ```
2136
- */
2137
- function translate(num: number, type?: 'cardinal' | 'ordinal' | 'suffix'): string;
2138
- /**
2139
- * Balances a number within a specified range
2140
- * @param amount - Number to balance
2141
- * @param min - Minimum value
2142
- * @param max - Maximum value
2143
- * @param decimals - Number of decimal places to round to (default is 0)
2144
- * @returns - Balanced number
2145
- * @example
2146
- * ```javascript
2147
- * const balancedValue = Simulation.number.balance(150, 0, 100);
2148
- * console.log(balancedValue); // 100
2149
- * ```
2150
- */
2151
- function balance(amount: number, min?: number, max?: number, decimals?: number): number;
2152
- /**
2153
- * Rounds a number to a specified number of decimal places
2154
- * @param value - Number to round
2155
- * @param decimals - Number of decimal places (default is 2)
2156
- * @returns Rounded number
2157
- * @example
2158
- * ```javascript
2159
- * const roundedValue = Simulation.number.round(3.14159, 3);
2160
- * console.log(roundedValue); // 3.142
2161
- * ```
2162
- */
2163
- function round(value: number, decimals?: number): number;
2164
- /**
2165
- * Generate random number
2166
- * @param min - Minimum value
2167
- * @param max - Maximum value
2168
- * @param float - Number of decimal places (0 for integer)
2169
- * @returns - Random number
2170
- * @example
2171
- * ```javascript
2172
- * const intNumber = number.random(1, 10);
2173
- * console.log(intNumber); // e.g. 7
2174
- *
2175
- * const floatNumber = number.random(1, 10, 2);
2176
- * console.log(floatNumber); // e.g. 3.14
2177
- * ```
2178
- */
2179
- function number(min: number, max: number, float?: number): number;
2180
- }
2181
- namespace element {
2182
- interface ScaleOptions<T extends HTMLElement> {
2183
- /**
2184
- * The parent element to use for scaling calculations. If not provided, the element's parent will be used.
2185
- */
2186
- parent?: HTMLElement;
2187
- /**
2188
- * The preferred dimension to base the scaling on. Can be 'width', 'height', or 'auto' (default).
2189
- */
2190
- prefer?: 'width' | 'height' | 'auto';
2191
- /**
2192
- * The minimum percentage of the parent size to scale to. Default is 0.
2193
- */
2194
- min?: number;
2195
- /**
2196
- * The maximum percentage of the parent size to scale to. Default is 1 (100%).
2197
- */
2198
- max?: number;
2199
- /**
2200
- * A callback function that is called after scaling is applied.
2201
- * @param this - The HTML element being scaled.
2202
- * @param number - The scale factor applied to the element.
2203
- * @param element - The HTML element being scaled.
2204
- * @returns void
2205
- */
2206
- apply?: (this: T, number: number, element: T) => void;
2207
- }
2208
- type FitTextOptions = {
2209
- minFontSize?: number;
2210
- maxFontSize?: number;
2211
- parent?: HTMLElement;
3025
+ type TopType = {
3026
+ gifter: boolean;
3027
+ tip: {
3028
+ session: {
3029
+ donator: boolean;
3030
+ donation: boolean;
2212
3031
  };
2213
- /**
2214
- * Merges outer span styles with inner span styles in the provided HTML string.
2215
- * @param outerStyle - The style string to be applied to the outer span.
2216
- * @param innerHTML - The inner HTML string which may contain a span with its own styles.
2217
- * @returns A new HTML string with merged styles applied to a single span.
2218
- * @example
2219
- * ```javascript
2220
- * const result = mergeSpanStyles("color: red; font-weight: bold;", '<span style="font-size: 14px;">Hello World</span>');
2221
- * console.log(result); // Output: '<span style="font-size: 14px; color: red; font-weight: bold;">Hello World</span>'
2222
- * ```
2223
- */
2224
- function mergeSpanStyles(outerStyle: string, innerHTML: string, className?: string): string;
2225
- /**
2226
- * Scales an HTML element to fit within its parent element based on specified minimum and maximum scale factors.
2227
- * @param element - The HTML element to be scaled.
2228
- * @param min - Minimum scale factor (default is 0).
2229
- * @param max - Maximum scale factor (default is 1).
2230
- * @param options - Optional settings for scaling.
2231
- * @returns - An object containing the new width, height, and scale factor, or void if not applied.
2232
- * @example
2233
- * ```javascript
2234
- * const element = document.getElementById('myElement');
2235
- * scale(element, 0.5, 1, { return: false });
2236
- * ```
2237
- */
2238
- function scale(element: HTMLElement, min?: number, max?: number, options?: {
2239
- return: boolean;
2240
- parent: HTMLElement;
2241
- base: 'width' | 'height';
2242
- }): {
2243
- width: number;
2244
- height: number;
2245
- scale: number;
2246
- } | void;
2247
- /**
2248
- * Scales an HTML element to fit within its parent element based on specified options.
2249
- * @param element - The HTML element to be scaled.
2250
- * @param options - Optional settings for scaling.
2251
- * @returns The scale factor applied to the element.
2252
- * @example
2253
- * ```javascript
2254
- * const element = document.getElementById('myElement');
2255
- * const scaleFactor scalev2(element, {
2256
- * min: 0.5,
2257
- * max: 1,
2258
- * prefer: 'width',
2259
- * apply: (scale, el) => el.style.transform = `scale(${scale})`
2260
- * });
2261
- * console.log(`Element scaled by a factor of ${scaleFactor}`);
2262
- * ```
2263
- */
2264
- function scalev2<T extends HTMLElement>(element: T, options?: ScaleOptions<T>): number;
2265
- /**
2266
- * Fits the text within the parent element by adjusting the font size.
2267
- * @param element - The HTML element containing the text to be fitted.
2268
- * @param compressor - A multiplier to adjust the fitting sensitivity (default is 1).
2269
- * @param options - Optional settings for fitting text.
2270
- * @returns The HTML element with adjusted font size.
2271
- * @example
2272
- * ```javascript
2273
- * const element = document.getElementById('myTextElement');
2274
- * fitText(element, 1, { minFontSize: 12, maxFontSize: 36 });
2275
- * console.log(`Adjusted font size: ${element.style.fontSize}`);
2276
- * ```
2277
- */
2278
- function fitText(element: HTMLElement, compressor?: number, options?: FitTextOptions): HTMLElement;
2279
- /**
2280
- * Wraps formatted HTML text with containers and splits characters into indexed spans.
2281
- * Adds 'container' class and data-index to all parent elements, and wraps each character in a span with class 'char' and data-index.
2282
- * @param htmlString - The input HTML string containing formatted text elements (span, strong, em, etc).
2283
- * @param startIndex - The starting index for the data-index attribute (default is 0).
2284
- * @returns - A new HTML string with containers and character-level indexing.
2285
- * @example
2286
- * ```javascript
2287
- * const result = splitTextToChars('<span>TesTe</span> <strong>bold</strong>', 0);
2288
- * console.log(result);
2289
- * // Output: '<span class="container" data-index="0"><span class="char" data-index="0">T</span><span class="char" data-index="1">e</span>...'
2290
- * ```
2291
- */
2292
- function splitTextToChars(htmlString: string, startIndex?: number, preserveInterElementWhitespace?: boolean): string;
2293
- }
2294
- namespace object {
2295
- /**
2296
- * Flattens a nested object into a single-level object with dot-separated keys.
2297
- * @param obj - The nested object to be flattened.
2298
- * @param prefix - The prefix to be added to each key (used for recursion).
2299
- * @returns A flattened object with dot-separated keys.
2300
- * @example
2301
- * ```javascript
2302
- * const nestedObj = { a: { b: 1, c: { d: 2 } }, e: [3, 4] };
2303
- * const flatObj = flatten(nestedObj);
2304
- * console.log(flatObj);
2305
- * // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' }
2306
- * ```
2307
- */
2308
- function flatten(obj: Record<string, any>, stringify?: boolean, prefix?: string): Record<string, typeof stringify extends true ? string : string | number | boolean>;
2309
- /**
2310
- * Returns the entries of an object as an array of key-value pairs, with proper typing.
2311
- * @param obj - The object to retrieve entries from.
2312
- * @returns An array of key-value pairs from the object, typed as an array of tuples with key and value types.
2313
- */
2314
- function entries<K extends string, V>(obj: Record<K, V>): [K, V][];
2315
- /**
2316
- * Returns the values of an object as an array, with proper typing.
2317
- * @param obj - The object to retrieve values from.
2318
- * @returns An array of values from the object, typed as an array of the value type.
2319
- */
2320
- function values<K extends string, V>(obj: Record<K, V>): V[];
2321
- /**
2322
- * Returns the keys of an object as an array of strings, with proper typing.
2323
- * @param obj - The object to retrieve keys from.
2324
- * @returns An array of keys from the object, typed as an array of strings.
2325
- */
2326
- function keys<K extends string, V>(obj: Record<K, V>): K[];
2327
- }
2328
- namespace message {
2329
- type BadgeOptions = Twitch.roles[] | Twitch.roles | `${Twitch.roles}/${number}` | `${Twitch.roles}/${number}`[];
2330
- type TwitchResult = {
2331
- keys: Twitch.roles[];
2332
- badges: Twitch.badge[];
2333
- amount: {
2334
- [K in Twitch.roles]?: number;
2335
- };
3032
+ weekly: {
3033
+ donator: boolean;
3034
+ donation: boolean;
2336
3035
  };
2337
- type YouTubeResult = {
2338
- isVerified: boolean;
2339
- isChatOwner: boolean;
2340
- isChatSponsor: boolean;
2341
- isChatModerator: boolean;
3036
+ monthly: {
3037
+ donator: boolean;
3038
+ donation: boolean;
2342
3039
  };
2343
- /**
2344
- * Finds emotes in a given text.
2345
- * @param text - The text to search for emotes.
2346
- * @param emotes - An array of emotes to search for. Defaults to Local data emotes.
2347
- * @returns An array of emotes found in the text with their positions.
2348
- */
2349
- function findEmotesInText(text: string, emotes?: Emote[]): Emote[];
2350
- /**
2351
- * Replaces emotes in the text with corresponding HTML image tags.
2352
- * @param text - The text containing emotes.
2353
- * @param emotes - An array of emotes with their positions in the text.
2354
- * @returns The text with emotes replaced by HTML image tags.
2355
- */
2356
- function replaceEmotesWithHTML(text: string, emotes: Emote[]): string;
2357
- /**
2358
- * Checks if the text contains only emotes and whitespace.
2359
- * @param text - The text to check.
2360
- * @param emotes - An array of emotes with their positions in the text.
2361
- * @returns True if the text contains only emotes and whitespace, false otherwise.
2362
- */
2363
- function hasOnlyEmotes(text: string, emotes: Emote[]): boolean;
2364
- /**
2365
- * Replaces YouTube emotes in the text with corresponding HTML image tags.
2366
- * @param text - The text containing YouTube emotes.
2367
- * @param emotes - An array of YouTube emotes. Defaults to Local data YouTube emotes.
2368
- * @returns The text with YouTube emotes replaced by HTML image tags.
2369
- */
2370
- function replaceYoutubeEmotesWithHTML(text: string, emotes?: {
2371
- emojiId: string;
2372
- shortcuts: string[];
2373
- searchTerms: string[];
2374
- image: {
2375
- thumbnails: {
2376
- url: string;
2377
- width: number;
2378
- height: number;
2379
- }[];
2380
- accessibility: {
2381
- accessibilityData: {
2382
- label: string;
2383
- };
2384
- };
2385
- };
2386
- isCustomEmoji: boolean;
2387
- index: number;
2388
- }[]): string;
2389
- /**
2390
- * Generates badge data based on the provided badges and platform.
2391
- * @param badges - The badges to generate. Can be an array or a comma-separated string.
2392
- * @param provider - The platform provider ('twitch' or 'youtube'). Defaults to 'twitch'.
2393
- * @returns A promise that resolves to the generated badge data.
2394
- * @example
2395
- * ```javascript
2396
- * // Generate Twitch badges
2397
- * const twitchBadges = await generateBadges(['broadcaster', 'moderator'], 'twitch');
2398
- * // Generate YouTube badges
2399
- * const youtubeBadges = await generateBadges('sponsor, moderator', 'youtube');
2400
- * ```
2401
- */
2402
- function generateBadges<T extends Provider$1>(badges: BadgeOptions | undefined, provider: T): Promise<T extends 'twitch' ? TwitchResult : YouTubeResult>;
2403
- }
2404
- namespace event {
2405
- /**
2406
- * Parses the provider information from the event detail object.
2407
- * @param detail - The event detail object received from the StreamElements event.
2408
- * @returns An object containing the provider and the original event data.
2409
- */
2410
- function parseProvider(detail: StreamElements.Event.onEventReceived, _provider?: Provider$1): ClientEvents$1;
2411
- }
2412
- namespace string {
2413
- type Modifier = (value: string, param: string | null | undefined, values: {
2414
- amount?: number;
2415
- count?: number;
2416
- }) => string;
2417
- const PRESETS: Record<string, string>;
2418
- /**
2419
- * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
2420
- * @param string - The input string to perform replacements on.
2421
- * @param pattern - The pattern to match in the string (can be a string or a regular expression).
2422
- * @param callback - An asynchronous callback function that takes the matched substring and any captured groups as arguments and returns the replacement string.
2423
- * @returns A promise that resolves to the modified string with replacements applied.
2424
- * @example
2425
- * ```javascript
2426
- * const result = await string.replace("Hello World", /World/, async (match) => {
2427
- * return await fetchSomeData(match); // Assume this function fetches data asynchronously
2428
- * });
2429
- * console.log(result); // Output will depend on the fetched data
2430
- * ```
2431
- */
2432
- function replace(string: string, pattern: string, callback: (match: string, ...groups: string[]) => Promise<string> | string): Promise<string>;
2433
- /**
2434
- * Capitalizes the first letter of a given string.
2435
- * @param string - The input string to be capitalized.
2436
- * @returns The capitalized string.
2437
- * @example
2438
- * ```javascript
2439
- * const result = string.capitalize("hello world");
2440
- * console.log(result); // Output: "Hello world"
2441
- * ```
2442
- */
2443
- function capitalize(string: string): Capitalize<string>;
2444
- /**
2445
- * Composes a template string by replacing placeholders with corresponding values and applying optional modifiers.
2446
- * @param template - The template string containing placeholders in the format {key} and optional modifiers in the format [MODIFIER:param=value].
2447
- * @param values - An object containing key-value pairs to replace the placeholders in the template.
2448
- * @param options - Optional settings for the composition process.
2449
- * @returns The composed string with placeholders replaced and modifiers applied.
2450
- * @example
2451
- * ```javascript
2452
- * const { string } = Tixyel.Helper;
2453
- *
2454
- * // Basic usage with placeholders and simple modifiers
2455
- * const template1 = "Hello, {username}! You have {amount} [UPC=messages] and your name is [CAP=name].";
2456
- * const values1 = { username: "john_doe", amount: 5, name: "john" };
2457
- * const result1 = string.compose(template1, values1);
2458
- * // "Hello, john_doe! You have 5 MESSAGES and your name is John."
2459
- *
2460
- * // Multiple modifiers in a single block (HTML enabled)
2461
- * const template2 = "[COLOR:#ff0056,BOLD={username}]";
2462
- * const values2 = { username: "john_doe" };
2463
- * const result2 = string.compose(template2, values2, { html: true });
2464
- * // '<span class="color bold" style="color: #ff0056; font-weight: bold;">john_doe</span>'
2465
- *
2466
- * // Conditional rendering with IF (supports ===, >=, &&, ||, !, etc.)
2467
- * const template3 = "[IF=vip && status === 'live'?VIP Online|Offline]";
2468
- * const values3 = { status: 'live', vip: true };
2469
- * const result3 = string.compose(template3, values3);
2470
- * // "VIP Online"
2471
- *
2472
- * // Pluralization using amount / count or an explicit key
2473
- * const template4 = "You have {amount} [PLURAL=message|messages].";
2474
- * const values4 = { amount: 1 };
2475
- * const values5 = { amount: 3 };
2476
- * const result4a = string.compose(template4, values4); // "You have 1 message."
2477
- * const result4b = string.compose(template4, values5); // "You have 3 messages."
2478
- *
2479
- * // Number formatting
2480
- * const template5 = "Total: [NUMBER:2=amount] {currency}";
2481
- * const values6 = { amount: 1234.5, currency: '$' };
2482
- * const result5 = string.compose(template5, values6);
2483
- * // e.g. "Total: 1,234.50 $" (locale dependent)
2484
- *
2485
- * // Date and time formatting
2486
- * const template6 = "Created at: [DATE:iso=createdAt] ([DATE:relative=createdAt])";
2487
- * const values7 = { createdAt: new Date('2020-01-02T03:04:05.000Z') };
2488
- * const result6 = string.compose(template6, values7);
2489
- * // e.g. "Created at: 2020-01-02T03:04:05.000Z (Xs ago)"
2490
- *
2491
- * // MAP / SWITCH style mapping
2492
- * const template7 = "Status: [MAP:status=live:Online|offline:Offline|default:Unknown]";
2493
- * const values8 = { status: 'offline' };
2494
- * const result7 = string.compose(template7, values8);
2495
- * // "Status: Offline"
2496
- *
2497
- * // Escaping HTML
2498
- * const template8 = "[ESCAPE={message}]";
2499
- * const values9 = { message: '<b>Danger & "HTML"</b>' };
2500
- * const result8 = string.compose(template8, values9);
2501
- * // "&lt;b&gt;Danger &amp; &quot;HTML&quot;&lt;/b&gt;"
2502
- *
2503
- * // Using global presets
2504
- * Helper.string.PRESETS['alert'] = 'BOLD,COLOR:#ff0056';
2505
- * const template10 = "[PRESET:alert={username}]";
2506
- * const values11 = { username: 'john_doe' };
2507
- * const result10 = string.compose(template10, values11, { html: true });
2508
- * // '<span class="color bold" style="color: #ff0056; font-weight: bold;">john_doe</span>'
2509
- * ```
2510
- */
2511
- function compose(template: string, values?: Record<string, any>, options?: {
2512
- method?: 'loop' | 'index';
2513
- html?: boolean;
2514
- debug?: boolean;
2515
- modifiers?: Record<string, Modifier>;
2516
- aliases?: Record<string, string[]>;
2517
- }): string;
2518
- }
2519
- namespace sound {
2520
- let playing: boolean;
2521
- let audio: AudioContext;
2522
- /**
2523
- * Play sound from URL with optional volume and replace parameters
2524
- * @param url - Sound URL to play
2525
- * @param volume - Volume level from 0 to 100 (default: 100)
2526
- * @param replace - If true, replaces currently playing sound (default: false)
2527
- */
2528
- function play(url: string, volume?: number, replace?: boolean): void;
2529
- }
2530
- namespace color {
2531
- /**
2532
- * Generate opacity hex value
2533
- * @param opacity - Opacity value from 0 to 100
2534
- * @param color - Hex color code
2535
- * @returns - Hex color code with opacity
2536
- */
2537
- function opacity(opacity?: number, color?: string): string;
2538
- /**
2539
- * Extract color and opacity from hex code
2540
- * @param hex - Hex color code
2541
- * @returns - Object with color and opacity
2542
- */
2543
- function extract(hex: string): {
2544
- color: string;
2545
- opacity: number;
3040
+ alltime: {
3041
+ donator: boolean;
3042
+ donation: boolean;
2546
3043
  };
2547
- /**
2548
- * Validate color string format
2549
- * @param str - Color string to validate
2550
- * @returns Detected color format or false if invalid
2551
- * @example
2552
- * ```javascript
2553
- * const format1 = color.validate("#FF5733"); // "hex"
2554
- * const format2 = color.validate("rgb(255, 87, 51)"); // "rgb"
2555
- * const format3 = color.validate("hsl(14, 100%, 60%)"); // "hsl"
2556
- * const format4 = color.validate("orangered"); // "css-color-name"
2557
- * const format5 = color.validate("invalid-color"); // false
2558
- * ```
2559
- */
2560
- function validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name";
2561
- /**
2562
- * Convert color to different format
2563
- * @param str - Color string to convert (e.g. "#FF5733", "rgb(255, 87, 51)")
2564
- * @param format - Target format
2565
- * @returns - Converted color string
2566
- * @example
2567
- * ```javascript
2568
- * const hexColor = color.convert("rgb(255, 87, 51)", "hex"); // "#FF5733"
2569
- * const rgbColor = color.convert("#FF5733", "rgb"); // "rgb(255, 87, 51)"
2570
- * const hslColor = color.convert("#FF5733", "hsl"); // "hsl(14, 100%, 60%)"
2571
- * const colorName = color.convert("#FF5733", "css-color-name"); // "orangered"
2572
- * ```
2573
- */
2574
- function convert(str: string, format: 'hex' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): Promise<string | null>;
2575
- }
2576
- namespace random {
2577
- /**
2578
- * Generate random color
2579
- * @param type - Color format
2580
- * @returns - Random color in specified format
2581
- * @example
2582
- * ```javascript
2583
- * const hexColor = random.color('hex');
2584
- * console.log(hexColor); // e.g. #3e92cc
2585
- *
2586
- * const rgbColor = random.color('rgb');
2587
- * console.log(rgbColor); // e.g. rgb(62, 146, 204)
2588
- * ```
2589
- */
2590
- function color(type?: 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): string;
2591
- /**
2592
- * Generate random number
2593
- * @param min - Minimum value
2594
- * @param max - Maximum value
2595
- * @param float - Number of decimal places (0 for integer)
2596
- * @returns - Random number
2597
- * @example
2598
- * ```javascript
2599
- * const intNumber = random.number(1, 10);
2600
- * console.log(intNumber); // e.g. 7
2601
- *
2602
- * const floatNumber = random.number(1, 10, 2);
2603
- * console.log(floatNumber); // e.g. 3.14
2604
- * ```
2605
- */
2606
- function number(min: number, max: number, float?: number): number;
2607
- /**
2608
- * Generate random boolean
2609
- * @param threshold - Threshold between 0 and 1
2610
- * @returns - Random boolean
2611
- * @example
2612
- * ```javascript
2613
- * const boolValue = random.boolean(0.7);
2614
- * console.log(boolValue); // e.g. true (70% chance)
2615
- * ```
2616
- */
2617
- function boolean(threshold?: number): boolean;
2618
- /**
2619
- * Generate random string
2620
- * @param length - Length of the string
2621
- * @param chars - Characters to use
2622
- * @returns - Random string
2623
- * @example
2624
- * ```javascript
2625
- * const randString = random.string(10);
2626
- * console.log(randString); // e.g. "aZ3bT9xYqP"
2627
- * ```
2628
- */
2629
- function string(length: number, chars?: string): string;
2630
- /**
2631
- * Pick random element from array
2632
- * @param arr - Array to pick from
2633
- * @returns - Random element and its index
2634
- * @example
2635
- * ```javascript
2636
- * const [element, index] = random.array(['apple', 'banana', 'cherry']);
2637
- * console.log(element, index); // e.g. "banana", 1
2638
- * ```
2639
- */
2640
- function array<T>(arr: T[]): [value: T, index: number];
2641
- /**
2642
- * Generate random date
2643
- * @param start - Start date
2644
- * @param end - End date
2645
- * @returns - Random date between start and end
2646
- * @example
2647
- * ```javascript
2648
- * const randDate = random.date(new Date(2020, 0, 1), new Date());
2649
- * console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z
2650
- * ```
2651
- */
2652
- function date(start?: Date, end?: Date): Date;
2653
- /**
2654
- * Generate ISO date string offset by days
2655
- * @param daysAgo - Number of days to go back
2656
- * @returns - ISO date string
2657
- * @example
2658
- * ```javascript
2659
- * const isoDate = random.daysOffset(7);
2660
- * console.log(isoDate); // e.g. "2024-06-10T14:23:45.678Z"
2661
- *
2662
- * const isoDate30 = random.daysOffset(30);
2663
- * console.log(isoDate30); // e.g. "2024-05-18T09:15:30.123Z"
2664
- * ```
2665
- */
2666
- function daysOffset(daysAgo: number): string;
2667
- /**
2668
- * Generate UUID v4
2669
- * @returns - UUID string
2670
- * @example
2671
- * ```javascript
2672
- * const uuid = random.uuid();
2673
- * console.log(uuid); // e.g. "3b12f1df-5232-4e3a-9a0c-3f9f1b1b1b1b"
2674
- * ```
2675
- */
2676
- function uuid(): string;
2677
- }
2678
- namespace fn {
2679
- /**
2680
- * Apply function with given thisArg and arguments
2681
- * @param fn - Function to apply
2682
- * @param thisArg - Value to use as this when calling fn
2683
- * @param args - Arguments to pass to fn
2684
- * @returns Result of calling fn with thisArg and args
2685
- */
2686
- function apply<TThis, TArgs extends unknown[], TReturn>(fn: (this: TThis, ...args: TArgs) => TReturn, thisArg: TThis, args: TArgs): TReturn;
2687
- /**
2688
- * Call function with given thisArg and arguments
2689
- * @param fn - Function to call
2690
- * @param thisArg - Value to use as this when calling fn
2691
- * @param args - Arguments to pass to fn
2692
- * @returns Result of calling fn with thisArg and args
2693
- */
2694
- function call<TThis, TArgs extends unknown[], TReturn>(fn: (this: TThis, ...args: TArgs) => TReturn, thisArg: TThis, ...args: TArgs): TReturn;
2695
- }
2696
- namespace utils {
2697
- /**
2698
- * Delays execution for a specified number of milliseconds.
2699
- * @param ms - The number of milliseconds to delay.
2700
- * @returns A Promise that resolves after the specified delay.
2701
- */
2702
- function delay<R extends any, M extends number>(ms: M, callback?: () => R): Promise<R | null>;
2703
- /**
2704
- * Returns typed entries of an object.
2705
- * @param obj - The object to get entries from.
2706
- * @returns An array of key-value pairs from the object.
2707
- */
2708
- function typedEntries<K extends string, V>(obj: Record<K, V> | Array<V>): [K, V][];
2709
- /**
2710
- * Returns typed values of an object.
2711
- * @param obj - The object to get values from.
2712
- * @returns An array of values from the object.
2713
- */
2714
- function typedValues<K extends string, V>(obj: Record<K, V> | Array<V>): V[];
2715
- /**
2716
- * Returns typed keys of an object.
2717
- * @param obj - The object to get keys from.
2718
- * @returns An array of keys from the object.
2719
- */
2720
- function typedKeys<K extends string, V>(obj: Record<K, V> | Array<V>): K[];
2721
- /**
2722
- * Selects an item based on weighted probabilities.
2723
- * @param items - An object where keys are items and values are their weights.
2724
- * @returns A randomly selected item based on the given probabilities.
2725
- */
2726
- function probability<K extends string, V extends number>(items: Record<K, V>): K | undefined;
2727
- }
3044
+ };
3045
+ cheer: {
3046
+ session: {
3047
+ donator: boolean;
3048
+ amount: boolean;
3049
+ };
3050
+ weekly: {
3051
+ donator: boolean;
3052
+ amount: boolean;
3053
+ };
3054
+ monthly: {
3055
+ donator: boolean;
3056
+ amount: boolean;
3057
+ };
3058
+ alltime: {
3059
+ donator: boolean;
3060
+ amount: boolean;
3061
+ };
3062
+ };
3063
+ superchat: {
3064
+ session: {
3065
+ donator: boolean;
3066
+ amount: boolean;
3067
+ };
3068
+ weekly: {
3069
+ donator: boolean;
3070
+ amount: boolean;
3071
+ };
3072
+ monthly: {
3073
+ donator: boolean;
3074
+ amount: boolean;
3075
+ };
3076
+ alltime: {
3077
+ donator: boolean;
3078
+ amount: boolean;
3079
+ };
3080
+ };
3081
+ };
3082
+ type IdentifyTwitchResult = {
3083
+ id: string;
3084
+ name: string;
3085
+ color: string;
3086
+ role: Twitch.tags;
3087
+ tags: Twitch.tags[];
3088
+ badges: string;
3089
+ tier?: 1 | 2 | 3;
3090
+ top: TopType;
3091
+ };
3092
+ type IdentifyYouTubeResult = {
3093
+ id: string;
3094
+ name: string;
3095
+ role: 'broadcaster' | 'moderator' | 'sponsor' | 'verified' | 'viewer';
3096
+ badges: unknown[];
3097
+ top: TopType;
3098
+ };
3099
+
3100
+ declare namespace Helper {
3101
+ const number: NumberHelper;
3102
+ const element: ElementHelper;
3103
+ const object: ObjectHelper;
3104
+ const message: MessageHelper;
3105
+ const event: EventHelper;
3106
+ const string: StringHelper;
3107
+ const sound: SoundHelper;
3108
+ const color: ColorHelper;
3109
+ const random: RandomHelper;
3110
+ const fn: FunctionHelper;
3111
+ const utils: UtilsHelper;
2728
3112
  }
2729
3113
 
2730
3114
  declare namespace Local {
@@ -2784,7 +3168,7 @@ declare namespace Local {
2784
3168
  message(data?: Partial<{
2785
3169
  name: string;
2786
3170
  message: string;
2787
- badges: Helper.message.BadgeOptions;
3171
+ badges: BadgeOptions;
2788
3172
  color: string;
2789
3173
  userId: string;
2790
3174
  msgId: string;
@@ -2844,7 +3228,7 @@ declare namespace Local {
2844
3228
  message(data?: Partial<{
2845
3229
  name: string;
2846
3230
  message: string;
2847
- badges: Helper.message.BadgeOptions;
3231
+ badges: BadgeOptions;
2848
3232
  color: string;
2849
3233
  userId: string;
2850
3234
  msgId: string;
@@ -2880,35 +3264,48 @@ declare namespace Local {
2880
3264
  function start(fieldsFile?: string[], dataFiles?: string[], session?: StreamElements.Session.Data): Promise<void>;
2881
3265
  }
2882
3266
 
2883
- declare namespace Data {
2884
- const avatars: string[];
2885
- const badges: Record<Twitch.roles, Twitch.badge>;
2886
- const css_color_names: string[];
2887
- const emotes: (TwitchEmote | BttvEmote | SeventvEmote)[];
2888
- const items: any[];
2889
- const messages: string[];
2890
- const names: string[];
2891
- const tiers: string[];
2892
- const tts: string[];
2893
- const youtube_emotes: {
2894
- emojiId: string;
2895
- shortcuts: string[];
2896
- searchTerms: string[];
2897
- image: {
2898
- thumbnails: {
2899
- url: string;
2900
- width: number;
2901
- height: number;
2902
- }[];
2903
- accessibility: {
2904
- accessibilityData: {
2905
- label: string;
2906
- };
2907
- };
2908
- };
2909
- isCustomEmoji: boolean;
2910
- index: number;
2911
- }[];
3267
+ declare class FakeUser {
3268
+ readonly id: string;
3269
+ readonly name: string;
3270
+ readonly login: string;
3271
+ badges: Twitch.tags[];
3272
+ isSubscriber: boolean;
3273
+ tier?: StreamElements.Event.Provider.Twitch.SubscriberTier;
3274
+ constructor(id: string, name: string, badges?: Twitch.tags[], isSubscriber?: boolean, tier?: StreamElements.Event.Provider.Twitch.SubscriberTier);
3275
+ }
3276
+ interface FakeUserPoolOptions {
3277
+ id?: string;
3278
+ badges?: Twitch.tags[];
3279
+ limits?: {
3280
+ [key in Twitch.tags]?: number;
3281
+ };
3282
+ fixed?: {
3283
+ [key in Twitch.tags]?: string[];
3284
+ };
3285
+ }
3286
+ type FakeUserPoolEvents = {
3287
+ 'warn': [warning: Error];
3288
+ };
3289
+ declare class FakeUserPool extends EventProvider<FakeUserPoolEvents> {
3290
+ readonly users: FakeUser[];
3291
+ readonly id: string;
3292
+ private readonly byId;
3293
+ private readonly byName;
3294
+ private readonly byBadge;
3295
+ private static fixUser;
3296
+ private static getRandomSubTier;
3297
+ constructor(names?: string[], options?: FakeUserPoolOptions);
3298
+ private start;
3299
+ pick(): FakeUser | null;
3300
+ getByName(name: string): FakeUser | null;
3301
+ getById(id: string): FakeUser | null;
3302
+ getByBadge(badge: Twitch.tags): FakeUser[];
3303
+ getToReply(target: {
3304
+ id?: string;
3305
+ name?: string;
3306
+ }, extend?: Partial<Twitch.Reply>): Twitch.Reply | null;
3307
+ buildTwitchMessage(messages?: string[]): Parameters<(typeof Local)['emulate']['twitch']['message']>[0];
3308
+ buildYouTubeMessage(messages?: string[]): Parameters<(typeof Local)['emulate']['youtube']['message']>[0];
2912
3309
  }
2913
3310
 
2914
3311
  type MessageMap = Record<string, any>;
@@ -2976,6 +3373,7 @@ declare const main: {
2976
3373
  useQueue: typeof useQueue;
2977
3374
  useLogger: typeof useLogger;
2978
3375
  useComms: typeof useComms;
3376
+ FakeUserPool: typeof FakeUserPool;
2979
3377
  };
2980
3378
  actions: {
2981
3379
  Button: typeof Button;
@@ -2989,6 +3387,7 @@ declare const main: {
2989
3387
  usedComms: useComms<any>[];
2990
3388
  usedCommands: Command[];
2991
3389
  usedButtons: Button[];
3390
+ fakeUserPools: FakeUserPool[];
2992
3391
  };
2993
3392
  pronouns: {
2994
3393
  Alejo: typeof Alejo;
@@ -3012,4 +3411,4 @@ declare global {
3012
3411
  }
3013
3412
 
3014
3413
  export { Alejo, Button, Command, EventProvider, StreamElements, StreamElementsEvents, Twitch, TwitchEvents, YoutubeEvents, main as default, useComfyJs, useLogger, useQueue, useStorage };
3015
- export type { BttvEmote, ClientEvents$1 as ClientEvents, Emoji, Emote, Provider$1 as Provider, SeventvEmote, TwitchEmote };
3414
+ export type { BttvEmote, ClientEvents$1 as ClientEvents, Emoji, Emote, FfzEmote, JSONObject, JSONPrimitive, JSONSerializable, MapNumberValuesToString, NumberAsString, PathValue, Provider$1 as Provider, RequireAtLeastOne, SeventvEmote, TwitchEmote };