Skip to content

Giveaway command

Pascal Pohl edited this page Oct 19, 2019 · 1 revision

Here's an example on how to implement a giveaway:

Trigger: !giveawayStart

This command will start a giveaway.

{% delete $giveaway %}
{% set $giveawayRunning < 1 %}
Giveaway is now running. Use !giveaway to buy one (or more) tickets for 100 points.

Trigger: !giveaway

Will add the user to the giveaway list. If the user already exists it will still add further entries of the user. This will let users greater their chances to win.

{% if $giveawayRunning = 1 %}
    {% add /sender > $giveaway %}
{% else %}
    No giveaway is running.
    {% add 100 > /points[/senderlogin] %}{% <- this will give the users their points back %}
{% endif %}

If only one "ticket" per user should be allowed try something like this:

{% if $giveawayRunning = 1 %}
    {% if $giveaway includes /sender %}
        {% add 100 > /points[/senderlogin] %}
    {% else %}
        {% add /sender > $giveaway %}
    {% endif %}
{% else %}
    No giveaway is running.
    {% add 100 > /points[/senderlogin] %}
{% endif %}

Trigger: !giveawayEnd

This will end the giveaway and draw a winner.

{% set $giveawayWinner < $giveaway[/random] %}
{% set $giveawayRunning < 0 %}
And the winner is... 🥁
{% wait 5 %}{% <- Build up suspense... %}
🎉 {% print $giveawayWinner %} 🎉