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
- Engine v2
- Engine v1
Emoji of the dayAdvanced Script
const emoji = random.item(["🌟", "🚀", "💎", "🌈"]);
async.messages.send(`Your Emoji of the Day is: ${emoji}`);
Your Emoji of the Day is: {{randItem "🌟" "🚀" "💎" "🌈"}}
Kill Counter
- Engine v2
- Engine v1
Kill counterAdvanced Script
const kills = counters.add("killcounter", 1);
async.messages.send(`The streamer has ${kills} kills.`);
The streamer has {{kicklet.CounterAdd "killcounter" 1}} kills.
Minecraft Server Players
- Engine v2
- Engine v1
Minecraft playersAdvanced Script
const players = minecraft.players("hypixel.net");
async.messages.send(`There are currently ${players} players on Hypixel.net!`);
There are currently {{minecraft.Players "hypixel.net"}} players on Hypixel.net!
Random Joke
- Engine v2
- Engine v1
Random jokeAdvanced Script
const joke = http.getJson("https://official-joke-api.appspot.com/random_joke");
async.messages.send(`${joke.setup} - ${joke.punchline}`);
{{$response := http.GetJson "https://official-joke-api.appspot.com/random_joke"}}
{{$response.setup}} - {{$response.punchline}}
Points Drop
Usage: !drop <amount>
- Engine v2
- Engine v1
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!`,
);
}
{{if eq (len args) 1}}
{{$points := index args 0}}
{{if and (isInt $points) (ge (parseInt $points) 1)}}
{{$parsedPoints := parseInt $points}}
{{$parsedPoints}} points have been distributed to {{kicklet.AddPointsViewers $parsedPoints}} chatters!
{{else}}
Please enter a valid point value.
{{end}}
{{else}}
Use: !drop <amount>
{{end}}
Roulette
Usage: !roulette <1-36|red|black> <points>
- Engine v2
- Engine v1
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);
{{if eq (len args) 2}}
{{$choice := upper (index args 0)}}
{{$points := index args 1}}
{{if and (isInt $points) (ge (parseInt $points) 1)}}
{{$bet := parseInt $points}}
{{$balance := kicklet.Points sender.String}}
{{if ge $balance $bet}}
{{$number := rand 0 36}}
{{$color := "GREEN"}}
{{if or (and (ge $number 1) (le $number 10)) (and (ge $number 19) (le $number 28))}}
{{if eq (mod $number 2) 1}}{{$color = "RED"}}{{else}}{{$color = "BLACK"}}{{end}}
{{else if or (and (ge $number 11) (le $number 18)) (and (ge $number 29) (le $number 36))}}
{{if eq (mod $number 2) 1}}{{$color = "BLACK"}}{{else}}{{$color = "RED"}}{{end}}
{{end}}
The ball lands on {{$number}} {{$color}}.
{{if or (and (or (eq $choice "BLACK") (eq $choice "RED")) (eq $choice $color)) (and (isInt $choice) (eq $number (parseInt $choice)))}}
{{kicklet.AddPoints sender.String $bet}} points after the win.
{{else}}
{{kicklet.RemovePoints sender.String $bet}} points after the loss.
{{end}}
{{else}}You cannot bet more points than you have.{{end}}
{{else}}Please enter a valid point value.{{end}}
{{else}}Invalid syntax. Use: !roulette <1-36 | BLACK | RED> <points>{{end}}
Slots
Usage: !slot <points>
- Engine v2
- Engine v1
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);
<template>
{{script.Call "main"}}
{{script.Var "message"}}
</template>
<script>
function main() {
const bet = Number($event.getCommandArgs()[0]);
const symbols = ["apple", "banana", "cherry", "grape", "lemon"];
const roll = [
symbols[Math.floor(Math.random() * symbols.length)],
symbols[Math.floor(Math.random() * symbols.length)],
symbols[Math.floor(Math.random() * symbols.length)]
];
message = roll.join(" | ");
}
</script>