* Get all actions from your connected Streamer.bot instance
(
action: string | Partial<Pick<StreamerbotAction, 'id' | 'name'>>,
args?: Record<string, any>,
options?: Partial<{
customEventResponse: boolean;
}>
)
| 869 | } |
| 870 | |
| 871 | /** |
| 872 | * Subscribe to events from your connected Streamer.bot instance |
| 873 | */ |
| 874 | public async subscribe(events: StreamerbotEventsSubscription | '*'): Promise<SubscribeResponse> { |
| 875 | const supportedEvents = await this.getSupportedEvents(); |
| 876 | |
| 877 | // subscribe to all if = '*' |
| 878 | if (events === '*') { |
| 879 | events = supportedEvents; |
| 880 | } |
| 881 | |
| 882 | for (const key in events) { |
| 883 | if (!key || key === 'err') continue; |
| 884 | |
| 885 | // Skip unknown keys |
| 886 | if (!(key in supportedEvents)) { |
| 887 | this.logger?.warn( |
| 888 | `Attempted to subscribe to empty or unknown event source: "${key}"`, |
| 889 | Object.keys(events), |
| 890 | ); |
| 891 | continue; |
| 892 | } |
| 893 | |
| 894 | const eventSource = key as keyof typeof events; |
| 895 | const eventTypes = events[eventSource] ?? []; |
| 896 | |
| 897 | if (eventTypes && eventTypes.length) { |
| 898 | const set = new Set([...(this.subscriptions[eventSource] ?? []), ...eventTypes]); |
| 899 | this.subscriptions[eventSource] = [...set] as any[]; |
| 900 | } |
no test coverage detected