DiscordBot (originally called MogiiBot3) is a C# Bot for DiscordApp which includes many different features such as allowing users to create their own profiles, earn EXP to Level Up and compete for #1 on the leaderboard, and many more features. DiscordBot uses MySQL to store user, channel and guild data to be used via commands through DiscordBot or to be viewed using the Web Application (which can be seen in the Additional Applications section below).
DiscordBot Web (not yet released) works with DiscordBot and adds new features such as viewing the leaderboard on the web, viewing user profiles, viewing guild bans and searching for users. I will be releasing this in the future for use, but for now, you may create your own by working with the data DiscordBot stores in the MySQL database.
For this part, I will run through how to install onto Windows OS. This project has not been tested with any other OS and may not work with them.
- Windows Operating System
- .NET Framework 4.6 Runtime or later
- A MySQL Database
- AppData Edit Permissions
- Access to
root
user account on MySQL Database (or any other account with permission to optionally create a new user and create a database).
Firstly, we're going to need a MySQL database to store our data, and a user account to access the database. MySQL by default creates a user, 'root' which we will need access to in order to create our own user and database.
- Start the MySQL Console and log in as 'root'. You may need to specify a password if you have changed it, or blank if you have not set one.
- Next, we're going to create a database. If you've already got one, you can skip this step. Type
CREATE DATABASE `database`;
replacingdatabase
with a database name. - Now, we're going to create a user to access this database. If you've already got one, you can skip this step. Type
GRANT ALL PRIVILEGES ON `database`.* TO 'user'@'host' IDENTIFIED BY 'password';
replacingdatabase
with the database we created in step 2,user
with a username,host
with the hostname (such as localhost) andpassword
with a strong password.
That should be the database ready to go. DiscordBot runs multiple SQL Scripts on startup to create tables within the database so we won't need to worry about creating them here.
In order to get a bot account, we're going to need to head to the Developer Portal on DiscordApp and login. Once logged in:
- Create a New Application and give it a name. Don't worry about the name as you can change it later if you wish.
- In the Application Settings, head to
Bot
, and clickAdd Bot
. This will add a Bot to your application and create aTOKEN
in the process. It is important that you keep that token a secret and do not share it! We'll need it later to connect DiscordBot to your Bot Application. - Next, we're going to need to get your bot connected to your guild. Head back to
General Information
and copy theCLIENT ID
. - Head to the Permission Calculator and insert your
CLIENT ID
into the Client ID textbox. This will generate a link below which you can use to invite the bot to your guild. - Click the link, and select the guild you wish to invite the bot into. You may require the
Manage Guild
permission to invite the bot to a guild you do not own.
From here, you can head back to your Bot Application and move onto the next steps in setting up DiscordBot.
Please Note: In order for DiscordBot to completely work, it needs the Administrator
Permission or the Manage Bans
Permission along with all the other general permissions. This is due to DiscordBot storing information in the database such as the guild bans to be used on the Web Application.
To install DiscordBot, we're going to need the executable files.
- Head over to releases and download the latest release.
- Extract the files into their own directory and head into it, followed by
/Release/
. - Run the executable
DiscordBot.exe
. From here, we have the application running, now we just need to set it up. - Read through the message prompts, completing the information as shown.
When asked for Bot Token: Head back to the Bot Application on the Developer Portal, and copy the `TOKEN` in the `Bot` setting and paste it into the console.
Console should clear after the Bot Token has been provided.
When asked for Database Hostname: This is the host of your database, as specified when setting up MySQL and the `host`.
Typically, this would be `localhost` or `127.0.0.1`.
When asked for Database Port: This is the port your MySQL Server is hosted on.
By default, this is port 3306. You can leave it blank if you don't know or haven't changed it.
When asked for Database Username: This is the user we created in setting up MySQL when we specified `user`.
By default, this is usually `root`, but you should change it to a user account you created. (Unsure why? You might want to look into MySQL Security and Root User Account)
When asked for Database Password: This is the password we associated with the account we created and specified in `password` when setting up MySQL.
You should not leave this field blank.
When asked for Database Name: This is the database we created while setting up MySQL. This should be what you specified as `database` in the setup phase.
If you haven't created a database, DiscordBot will automatically default to the database `discordbot` and attempt to create it.
DiscordBot should then attempt to create all the tables required to store information for the bot. After this process is completed, DiscordBot will start to run. Congratulations, you have successfully setup DiscordBot!
- Using libraries to interface with APIs
- Using JSON to store data
- Creating files to write and read from
- Using GitHub as a version control platform to manage the project
- Creating extension methods
- Using attributes to manage permissions and required conditions
- Using a module base to manage bot commands
- Using async and Task to allow code to execute and return
- Using branches and push requests to easily manage what is being worked on and test each new feature separately
- MySQL Databases to store data
- MySQL Commands to create a database and tables, and populate the tables with data which needs to be updated constantly
- Creating objects to easily manage data
- This project is still being added to as I continue to learn and think of new ideas and how to approach and execute them.