So you might’ve seen my projects on my github so for this post I will tell you all about my current project.

How it started

So one thing that can be great for a server is a simple economy, with lots to do to keep everyone entertained and maintain visits on your discord server. I started this project to start building onto my discord server and to teach other viewers on how I did it. This project took a very long time to get initially working as I kept trying to figure out what storage system to use. I chose mysql because its very easy for me to handle, I tried other methods but just couldn’t get them to work with the project correctly. So what I created first was the balance system to see the users balance. This one was fairly easy compared to the other commands I created later on.

Balance Command

So the first thing you notice is the query command stating SELECT balance FROM economy WHERE ID = ?;. This query is asking the database if your entry in the database is valid so to get your balance. So next you’ll notice the command if (Object.keys(result).length === 0) {. This command is to detect whether or not the account exists. and if it doesn’t exist it will run the query INSERT INTO economy (ID, Balance) VALUES ('" + message.author.id + "', '0'); and will tell you that an account will be opened for you. Now you’ll be able to retype the command and see your balance.

Crime command

This was the second command that I created and this was was a bit tricky. The idea is that you run the command and have a chance to win 50K but with a risk of losing 100K. What I did was use the original command from the Balance command for entry detection however at the time of creation I did not have the time to fix the unable to give the winnings. So the reason I made it where there were ones with money and ones without is because I wanted to have risk but not make it to the point that you lose everything. I wanted to make it so it would be fun to use and not have people shy away. I have been considering adding more rewards and risk, but would really like some feedback on what could be added. As you’ll notice I added 6 success rates and the way it works is that var succesrate = Math.floor(Math.random() * (6-0)) + 0;. This command selects a number between 0 and 6 and acts accordingly to its if statement.

Work command

This was the third command. For this command I used the reward system similar to the crime command in reward as I give a reward from an amount of between 1 and 1000. This command is very simple and easy to understand. It also contains the entry check from the balance commands.

Slots command

This was the fourth command and this one was a bit more difficult to pull off. As with each command I used the entry check. Now it gets a little bit different as I added a balance check to see if they have a balance of more than 0. For this one we select a number between 0 and 2 times and use those values as fruits. Next it sends all 3 values in the form of the valued fruit. After that it asks if each of the 3 values are the same red red red orange orange orange yellow yellow yellow. If it hits all 3 of the chosen fruit it chooses a random number between 1 and 50000 to give award to the player.

Future commands

So far I have planned a roulette command, it is taking quite a bit of time to complete but so far I have all the data values in place for each bet. The bets added are red, black, dozen1, dozen2, dozen3, even, odd, low, high, column1, column2, and column3. If you have any suggestions on what other commands to add please leave in the comments.