Made the readme more readable, and added db-config.sql for easy importing of the database tables

This commit is contained in:
HerpieDerpie@example.com
2024-01-15 13:40:02 +01:00
parent 39c2ed3048
commit ce574e8f4b
2 changed files with 67 additions and 70 deletions

View File

@@ -1,89 +1,35 @@
# PS-Discord-BotBuilder
This is one of my personal projects, and I plan to update it for a while to come. This is a node.js webserver, which is hosting a website, with which you can "make" a discord bot.
This is one of my personal projects, and I plan to update it for a while to come. This is a node.js webserver, which is hosting a website, with which you can "make" a discord bot.s
<br>
### Node.js and NPM Setup
### Node.js and NPM Setup
When using this website, make sure you have [Node.js](https://nodejs.org/en) installed. When you are sure it's installed, clone the repository, and open a terminal in the folder. Then run the following command to install all required NPM packages
```bash
npm install archiver bcrypt body-parser express-session express fs-extra mysql path
```
<br>
### Database Setup
To get started with the project, you'll need to set up the database. Follow these steps:
1. **Database Creation:**
1. **Database Installation:**
- Make sure you have a MySQL server installed on your machine. If not, you can download and install it from [MySQL Downloads](https://dev.mysql.com/downloads/).
- Create a new database for your project.
- Make sure you have a MySQL server installed on your machine. If not, you can download and install it from [MySQL Downloads](https://dev.mysql.com/downloads/).
- Create a new database for your project.
2. **Database Schema:**
###### Table 1: `Commands`
- **Columns:**
- `command_id` (INT, Auto Increment, Primary Key)
- `project_id` (INT)
- `command_name` (VARCHAR)
- `command_description` (VARCHAR)
- `command_response` (VARCHAR)
- **Create Table Command:**
```sql
CREATE TABLE Commands (
command_id INT AUTO_INCREMENT PRIMARY KEY,
project_id INT,
command_name VARCHAR(255) NOT NULL,
command_description VARCHAR(255),
command_response VARCHAR(255)
);
```
###### Table 2: `Projects`
- **Columns:**
- `project_id` (INT, Auto Increment, Primary Key)
- `project_name` (VARCHAR)
- `project_owner` (VARCHAR)
- `bot_token` (VARCHAR)
- `bot_id` (VARCHAR)
- **Create Table Command:**
```sql
CREATE TABLE Projects (
project_id INT AUTO_INCREMENT PRIMARY KEY,
project_name VARCHAR(255) NOT NULL,
project_owner VARCHAR(36),
bot_token VARCHAR(255) NOT NULL,
bot_id VARCHAR(255) NOT NULL
);
```
###### Table 3: `Users`
- **Columns:**
- `user_id` (VARCHAR, Default: UUID(), Primary Key)
- `username` (VARCHAR)
- `password` (VARCHAR)
- **Create Table Command:**
```sql
CREATE TABLE Users (
user_id VARCHAR(36) DEFAULT UUID() PRIMARY KEY,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL
);
```
3. **Database Configuration:**
- Update the content in the config.json file, if you dont have it, feel free to make use of the config.json.example for the layout of the json file.
2. **Importing Tables:**:
- Import the db-config.sql file into your database using the following command:
```mysql -u {your_username} -p {your_database_name} < /path/to/db-config.sql```
- If you want to know more about the exact database structure, you can always take a look at the contents of `db-config.sql `
3. **Final Configuration:**
- Update the content in the config.json file. If you don't have it, feel free to make use of the config.json.example for the layout of the JSON file.
<br>
### Running the Application:
With the database set up and configured, you should be able to run your application. To run it, please use the following command
```bash
./startServer.sh
```

51
db-config.sql Executable file
View File

@@ -0,0 +1,51 @@
DROP TABLE IF EXISTS `Commands`;
CREATE TABLE `Commands` (
`command_id` int(11) NOT NULL AUTO_INCREMENT,
`project_id` int(11) DEFAULT NULL,
`command_name` varchar(255) NOT NULL,
`command_description` varchar(255) DEFAULT NULL,
`command_response` varchar(255) DEFAULT NULL,
PRIMARY KEY (`command_id`)
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
LOCK TABLES `Commands` WRITE;
INSERT INTO `Commands` VALUES (1,1,'ping','Get the current ping of the bot!','Pong!'),(3,1,'hihi','haha','hihihiha'),(9,3,'Command1','Command 1','Hello From Command 1!'),(10,2,'a','b','c'),(12,4,'a','a','a'),(13,4,'b','b','b'),(14,4,'c','c','c'),(15,4,'d','d','d'),(16,4,'e','e','e'),(17,4,'f','f','f'),(18,4,'g','g','g'),(19,4,'h','h','h'),(20,4,'i','i','i'),(21,4,'j','j','j'),(22,4,'k','k','k'),(23,4,'l','l','l'),(24,4,'m','m','m'),(25,4,'n','n','n'),(26,4,'o','o','o'),(27,4,'p','p','p'),(28,4,'q','q','q'),(29,4,'r','r','r'),(30,4,'s','s','s'),(31,4,'t','t','t'),(32,4,'u','u','u'),(33,4,'v','v','v'),(34,4,'w','w','w'),(35,4,'x','x','x'),(36,4,'y','y','y'),(37,4,'z','z','z'),(41,1,'hahaha','dit is episch command','frikaden');
UNLOCK TABLES;
DROP TABLE IF EXISTS `Projects`;
CREATE TABLE `Projects` (
`project_id` int(11) NOT NULL AUTO_INCREMENT,
`project_name` varchar(255) NOT NULL,
`project_owner` varchar(36) DEFAULT NULL,
`bot_token` varchar(255) NOT NULL,
`bot_id` varchar(255) NOT NULL,
PRIMARY KEY (`project_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
LOCK TABLES `Projects` WRITE;
INSERT INTO `Projects` VALUES (1,'HerpesDerpesBot','4ad7671e-9f58-11ee-8679-77dce8f924c9','MTEzODM2OTYyMTgzODI3MDQ3NA.GeGOob.4o9KZlD2lQYU3Qd0lToyD-b29DvwhWyUUpQaRI','1138369621838270474'),(2,'TestToCHeckDBFixHIHI','4ad7671e-9f58-11ee-8679-77dce8f924c9','MTEzODM2OTYyMTgzODI3MDQ3NA.GeGOob.4o9KZlD2lQYU3Qd0lToyD-b29DvwhWyUUpQaRI','1138369621838270474'),(3,'TestBot','56c0bc05-9f58-11ee-8679-77dce8f924c9','12345','12345'),(4,'Frikandel','4ad7671e-9f58-11ee-8679-77dce8f924c9','12345','Mayonaise');
UNLOCK TABLES;
DROP TABLE IF EXISTS `Users`;
CREATE TABLE `Users` (
`user_id` varchar(36) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
LOCK TABLES `Users` WRITE;
INSERT INTO `Users` VALUES ('4ad7671e-9f58-11ee-8679-77dce8f924c9','valentijn','$2b$10$mica8GYsYCQ71mJzFAtf4uPueL2GMbmwZTkb22uzkeC4AtLyzi1kW'),('56c0bc05-9f58-11ee-8679-77dce8f924c9','user','$2b$10$l4z4m2vpcSvd/VwsLRRZF.6dElWoDevK25GRD1tBGtTy12SX93OiG');
UNLOCK TABLES;