♻️ Extract hidrate logic to server
This commit is contained in:
23
src/backend/pubSubClient/actions/hidrate.ts
Normal file
23
src/backend/pubSubClient/actions/hidrate.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { LOG_PREFIX } from "..";
|
||||
import { RedemptionMessage } from "../../../interfaces/RedemptionMessage";
|
||||
import { broadcast } from "../../helpers/webServer";
|
||||
import { getUsernameFromId } from "../../helpers/twitch";
|
||||
import { say } from "../../chatClient";
|
||||
|
||||
async function hidrate(msg: RedemptionMessage): Promise<void> {
|
||||
const channel = await getUsernameFromId(parseInt(msg.channelId));
|
||||
|
||||
if (!channel) {
|
||||
console.log(`${LOG_PREFIX}No channel found`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
msg.message = `@${msg.userDisplayName} ha invitado a una ronda`;
|
||||
|
||||
broadcast(JSON.stringify(msg));
|
||||
|
||||
await say(channel, "waterGang waterGang waterGang");
|
||||
}
|
||||
|
||||
export { hidrate };
|
@@ -6,6 +6,7 @@ import { UserIdResolvable } from "twitch";
|
||||
import { broadcast } from "../helpers/webServer";
|
||||
import { getApiClient } from "../helpers/twitch";
|
||||
import { getVip } from "./actions/getVip";
|
||||
import { hidrate } from "./actions/hidrate";
|
||||
import { russianRoulette } from "./actions/russianRoulette";
|
||||
import { stealVip } from "./actions/stealVip";
|
||||
import { timeoutFriend } from "./actions/timeoutFriend";
|
||||
@@ -66,6 +67,7 @@ async function onRedemption(message: PubSubRedemptionMessage) {
|
||||
}
|
||||
break;
|
||||
case RedemptionIds.Hidrate:
|
||||
await hidrate(msg);
|
||||
break;
|
||||
default:
|
||||
console.log(LOG_PREFIX, msg);
|
||||
|
Reference in New Issue
Block a user