1
0

♻️ Extract roussian roulette logic to server

This commit is contained in:
2022-01-05 19:01:15 +01:00
parent 05a93ba316
commit 2edb4481f8
4 changed files with 81 additions and 74 deletions

View File

@@ -6,6 +6,7 @@ import { UserIdResolvable } from "twitch";
import { broadcast } from "../helpers/webServer";
import { getApiClient } from "../helpers/twitch";
import { getVip } from "./actions/getVip";
import { russianRoulette } from "./actions/russianRoulette";
import { stealVip } from "./actions/stealVip";
const LOG_PREFIX = "[PubSub] ";
@@ -43,12 +44,10 @@ async function onRedemption(message: PubSubRedemptionMessage) {
};
switch (msg.rewardId) {
case RedemptionIds.StealVip:
if (await stealVip(msg)) {
msg.message = `@${msg.userDisplayName} ha "tomado prestado" el VIP de @${msg.message}`;
broadcast(JSON.stringify(msg));
}
case RedemptionIds.RussianRoulette:
await russianRoulette(msg);
break;
case RedemptionIds.TimeoutFriend:
break;
case RedemptionIds.GetVip:
msg.message = `@${msg.userDisplayName} ha encontrado diamantes!`;
@@ -57,6 +56,15 @@ async function onRedemption(message: PubSubRedemptionMessage) {
broadcast(JSON.stringify(msg));
}
break;
case RedemptionIds.StealVip:
if (await stealVip(msg)) {
msg.message = `@${msg.userDisplayName} ha "tomado prestado" el VIP de @${msg.message}`;
broadcast(JSON.stringify(msg));
}
break;
case RedemptionIds.Hidrate:
break;
default:
console.log(LOG_PREFIX, msg);