♻️ Update frontend logic with refactored types
This commit is contained in:
@@ -54,7 +54,7 @@ async function checkEvent(e) {
|
|||||||
break;
|
break;
|
||||||
// ruleta rusa
|
// ruleta rusa
|
||||||
case "a73247ee-e33e-4e9b-9105-bd9d11e111fc":
|
case "a73247ee-e33e-4e9b-9105-bd9d11e111fc":
|
||||||
await russianRoulette(data.userDisplayName);
|
await russianRoulette(data);
|
||||||
break;
|
break;
|
||||||
// timeout a un amigo
|
// timeout a un amigo
|
||||||
case "638c642d-23d8-4264-9702-e77eeba134de":
|
case "638c642d-23d8-4264-9702-e77eeba134de":
|
||||||
@@ -77,8 +77,12 @@ async function checkEvent(e) {
|
|||||||
case "232e951f-93d1-4138-a0e3-9e822b4852e0":
|
case "232e951f-93d1-4138-a0e3-9e822b4852e0":
|
||||||
data.message = `@${data.userDisplayName} ha invitado a una ronda.`;
|
data.message = `@${data.userDisplayName} ha invitado a una ronda.`;
|
||||||
sendWsActions({
|
sendWsActions({
|
||||||
action: "say",
|
type: "say",
|
||||||
message: "FunnyCatTastingTHEWATER FunnyCatTastingTHEWATER FunnyCatTastingTHEWATER"
|
channelId: data.channelId,
|
||||||
|
userId: data.userId,
|
||||||
|
data: {
|
||||||
|
message: "waterGang waterGang waterGang"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
await createCard(data.rewardName, data.message, data.backgroundColor, data.rewardImage);
|
await createCard(data.rewardName, data.message, data.backgroundColor, data.rewardImage);
|
||||||
break;
|
break;
|
||||||
@@ -148,7 +152,7 @@ function karaokeTime(username, message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let rrAttemps = 0;
|
let rrAttemps = 0;
|
||||||
function russianRoulette(username) {
|
function russianRoulette({ channelId, userId, userDisplayName }) {
|
||||||
return new Promise(res => {
|
return new Promise(res => {
|
||||||
const win = rando(5 - rrAttemps) !== 0;
|
const win = rando(5 - rrAttemps) !== 0;
|
||||||
|
|
||||||
@@ -161,10 +165,10 @@ function russianRoulette(username) {
|
|||||||
const p = createText();
|
const p = createText();
|
||||||
|
|
||||||
if (win) {
|
if (win) {
|
||||||
p.innerText = `${username} ha sido afortunado y aún sigue entre nosotros`;
|
p.innerText = `${userDisplayName} ha sido afortunado y aún sigue entre nosotros`;
|
||||||
rrAttemps = 0;
|
rrAttemps = 0;
|
||||||
} else {
|
} else {
|
||||||
p.innerText = `${username} se ha ido a un mundo mejor, siempre te recordaremos`;
|
p.innerText = `${userDisplayName} se ha ido a un mundo mejor, siempre te recordaremos`;
|
||||||
rrAttemps++;
|
rrAttemps++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,21 +185,33 @@ function russianRoulette(username) {
|
|||||||
img.classList.add("shoot");
|
img.classList.add("shoot");
|
||||||
|
|
||||||
actions.push({
|
actions.push({
|
||||||
action: "timeout",
|
type: "timeout",
|
||||||
username: username,
|
userId,
|
||||||
|
channelId,
|
||||||
|
data: {
|
||||||
|
username: userDisplayName,
|
||||||
time: "60",
|
time: "60",
|
||||||
reason: "F en la ruleta."
|
reason: "F en la ruleta."
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
actions.push({
|
actions.push({
|
||||||
action: "say",
|
type: "say",
|
||||||
message: `PepeHands ${username} no ha sobrevivido para contarlo.`
|
userId,
|
||||||
|
channelId,
|
||||||
|
data: {
|
||||||
|
message: `PepeHands ${userDisplayName} no ha sobrevivido para contarlo.`
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
actions.push({
|
actions.push({
|
||||||
action: "say",
|
type: "say",
|
||||||
message: `rdCool Clap ${username}`
|
userId,
|
||||||
|
channelId,
|
||||||
|
data: {
|
||||||
|
message: `rdCool Clap ${userDisplayName}`
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,10 +236,14 @@ async function timeoutFriend(data) {
|
|||||||
const receptorUser = data.message.split(" ")[0];
|
const receptorUser = data.message.split(" ")[0];
|
||||||
|
|
||||||
sendWsActions({
|
sendWsActions({
|
||||||
action: "timeout",
|
type: "timeout",
|
||||||
|
userId: data.userId,
|
||||||
|
channelId: data.channelId,
|
||||||
|
data: {
|
||||||
username: receptorUser,
|
username: receptorUser,
|
||||||
time: "60",
|
time: "60",
|
||||||
reason: `Timeout dado por @${senderUser} con puntos del canal.`
|
reason: `Timeout dado por @${senderUser} con puntos del canal.`
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const cardMessage = `@${senderUser} ha expulsado a @${receptorUser} por 60 segundos.`;
|
const cardMessage = `@${senderUser} ha expulsado a @${receptorUser} por 60 segundos.`;
|
||||||
@@ -235,10 +255,14 @@ async function highlightMessage(data) {
|
|||||||
|
|
||||||
if (urlRegex.test(data.message)) {
|
if (urlRegex.test(data.message)) {
|
||||||
sendWsActions({
|
sendWsActions({
|
||||||
action: "timeout",
|
type: "timeout",
|
||||||
|
userId: data.userId,
|
||||||
|
channelId: data.channelId,
|
||||||
|
data: {
|
||||||
username: data.userDisplayName,
|
username: data.userDisplayName,
|
||||||
time: "10",
|
time: "10",
|
||||||
reason: "No esta permitido enviar enlaces en mensajes destacados."
|
reason: "No esta permitido enviar enlaces en mensajes destacados."
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -247,18 +271,15 @@ async function highlightMessage(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function giveTempVip(data) {
|
async function giveTempVip(data) {
|
||||||
const username = data.userDisplayName;
|
|
||||||
const channel = data.channelId;
|
|
||||||
|
|
||||||
sendWsActions([{
|
sendWsActions([{
|
||||||
action: "addVip",
|
type: "addVip",
|
||||||
channel,
|
userId: data.userId,
|
||||||
username
|
channelId: data.channelId
|
||||||
}, {
|
}, {
|
||||||
scheduledAt: Date.now() + 1000 * 60 * 60 * 24 * 7,
|
scheduledAt: Date.now() + 1000 * 60 * 60 * 24 * 7,
|
||||||
action: "removeVip",
|
type: "removeVip",
|
||||||
channel,
|
userId: data.userId,
|
||||||
username
|
channelId: data.channelId
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,13 +295,11 @@ function sendWsActions(actions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ws.readyState === WebSocket.OPEN) {
|
if (ws.readyState === WebSocket.OPEN) {
|
||||||
|
|
||||||
if (actions.length > 0) {
|
if (actions.length > 0) {
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
actions: actions
|
actions: actions
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
left: .5rem;
|
left: .5rem;
|
||||||
width: var(--playerWidth);
|
width: var(--playerWidth);
|
||||||
padding: .5rem;
|
padding: .5rem;
|
||||||
background-color: rgba(0, 0, 0, .5);
|
background-color: rgba(0, 0, 0, .85);
|
||||||
border-radius: .5rem;
|
border-radius: .5rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user