♻️ Remove non needed arguments and obtain values
using helpers
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { AuthProvider } from "twitch-auth";
|
import { getApiClient, getAuthProvider } from "../helpers/twitch";
|
||||||
|
|
||||||
import { ChatClient } from "twitch-chat-client";
|
import { ChatClient } from "twitch-chat-client";
|
||||||
import { getApiClient } from "../helpers/twitch";
|
|
||||||
import { sockets } from "../webServer";
|
import { sockets } from "../webServer";
|
||||||
import { start } from "../helpers/scheduledActions";
|
import { start } from "../helpers/scheduledActions";
|
||||||
|
|
||||||
@@ -14,7 +14,10 @@ export {
|
|||||||
say
|
say
|
||||||
};
|
};
|
||||||
|
|
||||||
async function connect(authProvider: AuthProvider, channels: Array<any>) {
|
async function connect(channels: Array<any>) {
|
||||||
|
const authProvider = await getAuthProvider(
|
||||||
|
|
||||||
|
);
|
||||||
if (
|
if (
|
||||||
chatClient &&
|
chatClient &&
|
||||||
(
|
(
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
import { getApiClient, getAuthProvider } from "./helpers/twitch";
|
|
||||||
|
|
||||||
import { connect } from "./chatClient";
|
import { connect } from "./chatClient";
|
||||||
import { listen } from "./webServer";
|
import { listen } from "./webServer";
|
||||||
import { registerUserListener } from "./pubSubClient";
|
import { registerUserListener } from "./pubSubClient";
|
||||||
@@ -7,12 +5,10 @@ import { registerUserListener } from "./pubSubClient";
|
|||||||
const channel = "alexbcberio";
|
const channel = "alexbcberio";
|
||||||
|
|
||||||
export async function bootstrap() {
|
export async function bootstrap() {
|
||||||
|
await Promise.all([
|
||||||
const apiClient = await getApiClient();
|
registerUserListener(channel),
|
||||||
await registerUserListener(apiClient, channel);
|
connect([channel]),
|
||||||
|
]);
|
||||||
const authProvider = await getAuthProvider();
|
|
||||||
await connect(authProvider, [channel]);
|
|
||||||
|
|
||||||
listen();
|
listen();
|
||||||
}
|
}
|
@@ -1,15 +1,17 @@
|
|||||||
import { ApiClient, UserIdResolvable } from "twitch";
|
|
||||||
import { PubSubClient, PubSubRedemptionMessage } from "twitch-pubsub-client";
|
import { PubSubClient, PubSubRedemptionMessage } from "twitch-pubsub-client";
|
||||||
import { broadcast, chatClient, say } from "../chatClient";
|
import { broadcast, chatClient, say } from "../chatClient";
|
||||||
|
import { getApiClient, getUsernameFromId } from "../helpers/twitch";
|
||||||
import { saveScheduledActions, scheduledActions } from "../helpers/scheduledActions";
|
import { saveScheduledActions, scheduledActions } from "../helpers/scheduledActions";
|
||||||
|
|
||||||
import { getUsernameFromId } from "../helpers/twitch";
|
import { UserIdResolvable } from "twitch";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
registerUserListener
|
registerUserListener
|
||||||
}
|
}
|
||||||
|
|
||||||
async function registerUserListener(apiClient: ApiClient, user?: UserIdResolvable) {
|
async function registerUserListener(user: UserIdResolvable) {
|
||||||
|
const apiClient = await getApiClient();
|
||||||
|
|
||||||
const pubSubClient = new PubSubClient();
|
const pubSubClient = new PubSubClient();
|
||||||
const userId = await pubSubClient.registerUserListener(apiClient, user);
|
const userId = await pubSubClient.registerUserListener(apiClient, user);
|
||||||
/*const listener = */ await pubSubClient.onRedemption(userId, onRedemption);
|
/*const listener = */ await pubSubClient.onRedemption(userId, onRedemption);
|
||||||
|
Reference in New Issue
Block a user