🎨 Change stealVip return type to boolean
Indicates if the vip has been successfuly stealed
This commit is contained in:
@@ -31,7 +31,7 @@ async function onRedemption(message: PubSubRedemptionMessage) {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const reward = message._data.data.redemption.reward;
|
const reward = message._data.data.redemption.reward;
|
||||||
|
|
||||||
let msg: any = {
|
const msg = {
|
||||||
id: message.id,
|
id: message.id,
|
||||||
channelId: message.channelId,
|
channelId: message.channelId,
|
||||||
rewardId: message.rewardId,
|
rewardId: message.rewardId,
|
||||||
@@ -48,17 +48,17 @@ async function onRedemption(message: PubSubRedemptionMessage) {
|
|||||||
switch (msg.rewardId) {
|
switch (msg.rewardId) {
|
||||||
// robar vip
|
// robar vip
|
||||||
case "ac750bd6-fb4c-4259-b06d-56953601243b":
|
case "ac750bd6-fb4c-4259-b06d-56953601243b":
|
||||||
msg = await stealVip(msg);
|
if (await stealVip(msg)) {
|
||||||
break;
|
msg.message = `@${msg.userDisplayName} ha robado el VIP a @${msg.message}.`;
|
||||||
}
|
|
||||||
|
|
||||||
if (msg) {
|
broadcast(JSON.stringify(msg));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
console.log(LOG_PREFIX, msg);
|
console.log(LOG_PREFIX, msg);
|
||||||
|
|
||||||
if (typeof msg !== "string") {
|
broadcast(JSON.stringify(msg));
|
||||||
msg = JSON.stringify(msg);
|
break;
|
||||||
}
|
|
||||||
broadcast(msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,12 +69,13 @@ async function stealVip(msg: {
|
|||||||
channelId: string;
|
channelId: string;
|
||||||
userDisplayName: string;
|
userDisplayName: string;
|
||||||
message: string;
|
message: string;
|
||||||
}) {
|
}): Promise<boolean> {
|
||||||
const channel = await getUsernameFromId(parseInt(msg.channelId));
|
const channel = await getUsernameFromId(parseInt(msg.channelId));
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
console.log(`${LOG_PREFIX}No channel found`);
|
console.log(`${LOG_PREFIX}No channel found`);
|
||||||
return;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const addVipUser = msg.userDisplayName;
|
const addVipUser = msg.userDisplayName;
|
||||||
@@ -93,12 +94,10 @@ async function stealVip(msg: {
|
|||||||
saveScheduledActions();
|
saveScheduledActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.message = `@${addVipUser} ha robado el VIP a @${removeVipUser}.`;
|
return true;
|
||||||
|
|
||||||
return msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// adds a user to vips
|
// adds a user to vips
|
||||||
|
Reference in New Issue
Block a user