- Create a discord bot (https://discord.com/developers/applications)
- Enable SERVER MEMBERS INTENT and MESSAGE CONTENT INTENT (https://discord.com/developers/applications/<<APPLICATION_ID>>/bot)
- Add the bot to your server (
https://discord.com/api/oauth2/authorize?client_id=<<BOT_ID>>&permissions=0&scope=bot%20applications.commands
) - Rename
.env_copy
to.env
and fill in the environment variables - On the first run, run the app with the
-addCommands
flag (and on any subsequent run that you wish to add/edit existing slash commands) - On every other run, run it without the flag as there is no need
(Oh, and have a PostgreSQL database set up)
- To add commands, head over to the
/src/discord
, which we’ll also denote as DISCORD_DIR - Find where
DISCORD_DIR/commands
your command should be - Create your own command file (for an example you can head over to
DISCORD_DIR/commands/games/coins/coin_flip.go
) - Go to
DISCORD_DIR/commands.go
, import the specific package of your new function, and at the end of theinit
function add your new command as other are added - Go to
DISCORD_DIR/commands/help.go
and add your new command to the list
- The code needs to be cleaned
- Better error checking for SQL queries
- Let the owner of the bot (or any other person you’d like) seed the RNG
- Edit the interaction of the user with slash commands
- Add new games
- Create leaderboards (i.e. biggest wins, highest balances)
Earlier this year I got my hands on a pretty awesome book by Mark Bollman, “Basic Gambling Mathematics: The Numbers Behind The Neon” that sparked an interest in how luck-based games work, having had experiences with CS:GO gambling websites in the past and online casinos (which I do NOT encourage at all, since the house always has an advantage). Leading to it, I told myself that I should create a discord bot for these luck games and see where it gets me
Yes, and no. For what it’s worth, for a demo no-real-money for-fun discord gambling bot, it is. If you wish to use it in actual production for a real casino, I’d recommend not to.
It is random enough for the chances to be fair.
The RNG (basically, math.rand) was tested on running 10,000 simulations, each with 1,000,000 random values for a coin flip. I have chosen this as the coin flip is a valid binomial experiment, thus making use of its distribution and having its distribution and standard deviation be easily calculated. The values haven’t been far from the 68-95-99.7 rule (results were: 67.32-95.49-99.8)