1
0

♻️ Cleaned lots of code and change getvip implementation

getVip is no longer time limited, it will remove it once a limit of
vip users is reached (to be implemented)
This commit is contained in:
2022-01-05 18:13:59 +01:00
parent bc401bd531
commit 05a93ba316
13 changed files with 162 additions and 92 deletions

View File

@@ -1,8 +1,11 @@
import { PubSubClient, PubSubRedemptionMessage } from "twitch-pubsub-client";
import { RedemptionIds } from "../../enums/Redemptions";
import { RedemptionMessage } from "../../interfaces/RedemptionMessage";
import { UserIdResolvable } from "twitch";
import { broadcast } from "../helpers/webServer";
import { getApiClient } from "../helpers/twitch";
import { getVip } from "./actions/getVip";
import { stealVip } from "./actions/stealVip";
const LOG_PREFIX = "[PubSub] ";
@@ -24,7 +27,7 @@ async function onRedemption(message: PubSubRedemptionMessage) {
// @ts-ignore
const reward = message._data.data.redemption.reward;
const msg = {
const msg: RedemptionMessage = {
id: message.id,
channelId: message.channelId,
rewardId: message.rewardId,
@@ -40,14 +43,20 @@ async function onRedemption(message: PubSubRedemptionMessage) {
};
switch (msg.rewardId) {
// robar vip
case "ac750bd6-fb4c-4259-b06d-56953601243b":
case RedemptionIds.StealVip:
if (await stealVip(msg)) {
msg.message = `@${msg.userDisplayName} ha robado el VIP a @${msg.message}.`;
msg.message = `@${msg.userDisplayName} ha "tomado prestado" el VIP de @${msg.message}`;
broadcast(JSON.stringify(msg));
}
break;
case RedemptionIds.GetVip:
msg.message = `@${msg.userDisplayName} ha encontrado diamantes!`;
if (await getVip(msg)) {
broadcast(JSON.stringify(msg));
}
break;
default:
console.log(LOG_PREFIX, msg);