import { eventSub } from "index";
import { sendMessage } from "lib/commandUtils";
import { redis } from "lib/redis";
import { streamerId } from "main";
import { sendDiscordMessage } from "web/discordConnection";

eventSub.onStreamOnline(streamerId, async (msg) => {
	await redis.set("streamIsLive", "1");
	await sendMessage(
		`${msg.broadcasterDisplayName.toUpperCase()} IS LIVE! START DIGGING!`,
	);
	await sendDiscordMessage({ message: "live" });
});

eventSub.onStreamOffline(streamerId, async (msg) => {
	await redis.del("streamIsLive");
	await sendMessage(
		`${msg.broadcasterDisplayName.toUpperCase()} IS OFFLINE! NO MORE FREE LOOT!`,
	);
});
