Skip to main content

Command Examples

These examples are starting points for custom commands. Engine v2 examples use Advanced Script. Engine v1 examples use the older Go-template response format.

Emoji of the Day

Emoji of the dayAdvanced Script
const emoji = random.item(["🌟", "🚀", "💎", "🌈"]);
async.messages.send(`Your Emoji of the Day is: ${emoji}`);

Kill Counter

Kill counterAdvanced Script
const kills = counters.add("killcounter", 1);
async.messages.send(`The streamer has ${kills} kills.`);

Minecraft Server Players

Minecraft playersAdvanced Script
const players = minecraft.players("hypixel.net");
async.messages.send(`There are currently ${players} players on Hypixel.net!`);

Random Joke

Random jokeAdvanced Script
const joke = http.getJson("https://official-joke-api.appspot.com/random_joke");
async.messages.send(`${joke.setup} - ${joke.punchline}`);

Points Drop

Usage: !drop <amount>

Points dropAdvanced Script
const amount = Number(args[0]);

if (!Number.isInteger(amount) || amount < 1) {
async.messages.send("Use: !drop <amount>");
} else {
const viewers = points.addActiveViewers(amount);
const currency = points.currency();

async.messages.send(
`${amount} ${currency} have been distributed to ${viewers} active chatters!`,
);
}

Roulette

Usage: !roulette <1-36|red|black> <points>

RouletteAdvanced Script
const choice = text.upper(args[0] || "");
const bet = Number(args[1]);
let message = "";

if (!choice || !Number.isInteger(bet) || bet < 1) {
message = "Invalid syntax. Use: !roulette <1-36 | BLACK | RED> <points>";
} else if (points.get(sender.username) < bet) {
message = "You cannot bet more points than you have.";
} else {
const number = random.int(0, 36);
let color = "GREEN";
if ((number >= 1 && number <= 10) || (number >= 19 && number <= 28)) {
color = number % 2 === 1 ? "RED" : "BLACK";
} else if ((number >= 11 && number <= 18) || (number >= 29 && number <= 36)) {
color = number % 2 === 1 ? "BLACK" : "RED";
}

let multiplier = 0;
if ((choice === "RED" || choice === "BLACK") && choice === color) multiplier = 2;
if (Number(choice) === number && number >= 1 && number <= 36) multiplier = 36;

const symbol = color === "RED" ? "red" : color === "BLACK" ? "black" : "green";
message = `The ball lands on ${number} ${symbol}. `;

if (multiplier > 0) {
const newBalance = points.add(sender.username, bet * (multiplier - 1));
message += `You won ${bet * multiplier} ${points.currency()} and now have ${newBalance}.`;
} else {
const newBalance = points.remove(sender.username, bet);
message += `You lost and now have ${newBalance} ${points.currency()}.`;
}
}

async.messages.send(message);

Slots

Usage: !slot <points>

SlotsAdvanced Script
const bet = Number(args[0]);
let message = "";

if (!Number.isInteger(bet) || bet < 1) {
message = "Invalid syntax. Use: !slot <points>";
} else if (points.get(sender.username) < bet) {
message = "You do not have enough points!";
} else {
const symbols = ["apple", "banana", "cherry", "grape", "lemon"];
const roll = [random.item(symbols), random.item(symbols), random.item(symbols)];
const won = roll[0] === roll[1] && roll[1] === roll[2];

if (won) {
const balance = points.add(sender.username, bet * 4);
message = `${roll.join(" | ")} - You won ${bet * 5} ${points.currency()}! Balance: ${balance}`;
} else {
const balance = points.remove(sender.username, bet);
message = `${roll.join(" | ")} - Better luck next time. Balance: ${balance}`;
}
}

async.messages.send(message);