A little Discord bot for making giveaways of random things to random server members. I quickly threw it together before Xmas to make a Steam keys giveaway for my friends, so it's rather hacky, but shouldn't have any breaking bugs. I may improve the code and add more features if I do any other giveaways in the future.
The bot can currently work only with one server. It is triggered by an event in that server. When the event starts, the bot will randomly select and announce the prize from a list you provide. When the event ends, the bot will select a random member with a certain role and announce the winner.
- Create a Discord application and give it
server members
intent access - Add it to your Discord server with a
bot
scope andSend Messages
permission - Create a Firebase project with a Firestore database and download credentials with access to it in .json format
- In the database, create a collection named
ConfigItem
. Each item should have a strictly definedid
and a single property called valuevalue
. All of them are mandatory and should be filled like this:discordapitoken
: Token for your Discord bot application created in step 1giveawaychannelid
: ID of a channel in which the bot will make announcementsgiveawayguildid
: ID of a guild in which the bot will conduct a giveawaygiveawayorganiserid
: ID of a person that will be mentioned to winners like "Please DM @organiser to claim your prize"giveawayroleid
: ID of a role that all participants have. Server members without this role can't win
- In the same database, create a collection named
Prize
. You can add as many prizes as you want here. IDs don't matter here but each item should have 3 fields:- eventid: empty string
- name: non-empty string, put the name of the prize here
- winnerid: empty string
- Clone the repo and compile it by running
go build .
- Move the resulting binary file to your VPS
- Place Firebase credentials .json file generated in step 3 alongside the binary and change its name to
firebase-credentials.json
- Run the binary and leave it like that
- Create one or more Discord events in your server
- Go back to the database, it should have an
Event
collection automatically created. Find the event(s) you created and switch theiertriggersraffle
property from false to true
All pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.