JS commands not working

Hey! I am having a problem with JS commands not triggering in chat. I even asked chatGPT and found no answers for reference this is my command that I want to start a raffle:

// === Config ===
const REWARD_AMOUNT = 2000;
const TEMP_VAR_KEY = “raffle_participants”;
const START_TIME_KEY = “raffle_start_time”;
const RAFFLE_DURATION_MS = 2 * 60 * 1000; // 2 minutes
const AUTHORIZED_USERS = [“broadcaster”, “mod”];

// === Context ===
let now = new Date().getTime();
let user = JS.datas(“nick”);
let displayName = JS.datas(“display_name”);
let role = JS.datas(“user_role”);
let alias = JS.wizebot.command.trigger_alias();

// === Raffle state ===
let participants = JS.wizebot.get_temp_var(TEMP_VAR_KEY) || ;
if (typeof participants === “string”) {
try {
participants = JSON.parse(participants);
} catch (e) {
participants = ;
}
}
let startTime = JS.wizebot.get_temp_var(START_TIME_KEY) || 0;

// === Helpers ===
function isModOrBroadcaster() {
return AUTHORIZED_USERS.includes(role);
}

function saveParticipants() {
JS.wizebot.set_temp_var(TEMP_VAR_KEY, participants, 5);
}

function clearRaffle() {
JS.wizebot.del_temp_var(TEMP_VAR_KEY);
JS.wizebot.del_temp_var(START_TIME_KEY);
}

// === Commands ===
function startRaffle() {
if (!isModOrBroadcaster()) {
JS.wizebot.send_chat_message(“Only mods or the broadcaster can start a raffle.”);
JS.utils.stop();
}

JS.wizebot.set_temp_var(TEMP_VAR_KEY, [], 5);
JS.wizebot.set_temp_var(START_TIME_KEY, now, 5);
JS.wizebot.send_chat_message("🎉 Raffle started! Type !join in chat to enter. You have 2 minutes!");

}

function joinRaffle() {
if (!startTime || now - startTime > RAFFLE_DURATION_MS) {
JS.wizebot.send_chat_message(“:stopwatch: The raffle is closed.”);
JS.utils.stop();
}

if (participants.includes(user)) {
    JS.wizebot.send_chat_message(displayName + ", you've already joined the raffle!");
    JS.utils.stop();
}

participants.push(user);
saveParticipants();
JS.wizebot.send_chat_message(displayName + " has joined the raffle!");

}

function pickWinnerIfTimeExpired() {
if (!startTime || now - startTime < RAFFLE_DURATION_MS) JS.utils.stop();

if (participants.length === 0) {
    JS.wizebot.send_chat_message("No one joined the raffle. 😢");
    clearRaffle();
    JS.utils.stop();
}

let winner = participants[JS.utils.random(0, participants.length - 1)];
JS.wizebot.currency.add(winner, REWARD_AMOUNT);
JS.wizebot.send_chat_message("🏆 The raffle is over! Congrats @" + winner + " for winning " + REWARD_AMOUNT + " coins!");
clearRaffle();

}

// === Router ===
if (alias === “!raffle”) {
startRaffle();
} else if (alias === “!join”) {
joinRaffle();
} else if (alias === “!pickraffle”) {
pickWinnerIfTimeExpired();
}

JS.utils.stop();

Hello,
Can you provide me with the name of your channel and the name of the command?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.