Back to Snippets

Giveaway Snippet.

This snippet lets you run a simple giveaway using buttons — one to enter, and one to end it manually. Since BDFD limits timed events to a maximum of 40 minutes, this avoids using timers entirely.
How to Use?
Add the commands with their respective triggers in your app. Avoid modifying anything unless you know what you're doing. Make sure to include two variables named: "giveawayParticipants" and "giveawayPrize" with empty values.
Credits
Inspired by some random code I found somewhere (probably copied, can't remember).

$nomention
$suppressErrors
$onlyPerms[managemessages;You need perms]
$onlyBotPerms[managemessages;I need perms]

$if[$message==]
Correct usage: !giveaway {prize}
$else
$c[Set dummy value so it's never empty]
$setServerVar[giveawayParticipants;]
$c[Store the prize]
$setServerVar[giveawayPrize;$message]
$c[Split participant list with ; separator]
$textSplit[$getServerVar[giveawayParticipants];\;]
$c[Count participants minus dummy entry]
$var[participantCount;$sub[$getTextSplitLength;1]]

$title[A New Giveaway Has Begun! 🎉]
$description[
🎁 **What's Up for Grabs?**
*$getServerVar[giveawayPrize]*

👤 **Hosted By:** <@$authorID>

👇 Want in? Smash the button below to join!

🏆 The winner will be picked manually via a button press — stay tuned!
]

$addTimestamp
$color[#2F3136]

$addButton[no;join_giveaway;Participate;secondary;no;]
$addButton[no;pick_winner-$authorID;Draw Winner;secondary;no;]

$endif