Skip to content

Commit

Permalink
Refactor & added "some" nice AI comments
Browse files Browse the repository at this point in the history
Refactored and modulated some of the code to improve readability and ease of modification. Complete folder restructure, including renaming of some files to have the same naming scheme/pattern.
  • Loading branch information
NotYourAverageGamer committed Jun 4, 2024
1 parent f13f268 commit 7e41465
Show file tree
Hide file tree
Showing 19 changed files with 323 additions and 261 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ replay_pid*
node_modules/

.eslintrc.json
*.DS_Store
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MCStatus Bot for Discord

MCStatus Bot for Discord is a bot designed to fetch the status of Minecraft servers and display that information in a Discord server. It periodically checks the status of Minecraft servers (Java Edition and Bedrock Edition) using user-provided API URLs from <https://mcstatus.io> and updates the server status on Discord using webhooks and embeds.
MCStatus Bot for Discord is a bot designed to fetch the status of Minecraft servers and display that information in a Discord server. It periodically checks the status of Minecraft servers (Java Edition and Bedrock Edition) using user-provided API URLs from [mcstatus.io](https://mcstatus.io) and updates the server status on Discord using webhooks and embeds.

## Features

Expand All @@ -12,17 +12,17 @@ MCStatus Bot for Discord is a bot designed to fetch the status of Minecraft serv

Before using the **MCStatus Bot for Discord**, make sure you have the following:

- `Node.js` installed. (<https://discordjs.guide/preparations/#installing-node-js>)
- `Node.js` installed. ([Installing Node.js](https://discordjs.guide/preparations/#installing-node-js))
- A Discord server where you have permissions to add bots and manage webhooks.
- **API URLs** for the Minecraft servers you want to monitor.
- **Java URL** example: `https://api.mcstatus.io/v2/status/java/YOUR.SERVER.IP`
- **Bedrock URL** example: `https://api.mcstatus.io/v2/status/bedrock/YOUR.SERVER.IP`
- A Discord webhook URL to send updates to your Discord server. (I use <https://discohook.org/> to POST my webhook. Formatting is handled in `main.js`)
- A `.env` file with necessary environment variables set (see/use `example.env` for reference/quick-setup).
- A Discord webhook URL to send updates to your Discord server. (You can obtain one from [Discohook](https://discohook.org/). Formatting is handled in `main.js`)
- A `.env` file with necessary environment variables set (copy/rename `example.env` for quick-setup).

## Installation

1. Download and unzip [**this**](https://github.com/NotYourAverageGamer/MCStatus-Bot-for-Discord/archive/refs/heads/main.zip) repo **OR** Clone it with:
1. Download and unzip [this repository](https://github.com/NotYourAverageGamer/MCStatus-Bot-for-Discord/archive/refs/heads/main.zip) **OR** Clone it with:

```bash
git clone https://github.com/NotYourAverageGamer/MCStatus-Bot-for-Discord.git
Expand All @@ -34,15 +34,16 @@ Before using the **MCStatus Bot for Discord**, make sure you have the following:
cd YOUR_PATH_TO/MCStatus-Bot-for-Discord
```

3. Install dependencies. Since we installed Node.JS earlier (which includes NPM and Discord.JS); to install the final dependencies we can simply run:
3. Install dependencies:

```bash
npm install
```

4. Rename `example.env` to `.env` and fill in the following environment variables.
- `API_URL_JAVA`: API URL for the Java Edition Minecraft server.
- `API_URL_BEDROCK`: API URL for the Bedrock Edition Minecraft server.
4. Copy/Rename `example.env` to `.env` and fill in the following environment variables:
- `SERVER_NAME`: Your server name, to be displayed as the title in the webhook.
- `JAVA_API_URL`: API URL for the Java Edition Minecraft server.
- `BEDROCK_API_URL`: API URL for the Bedrock Edition Minecraft server.
- `WEBHOOK_URL`: Discord webhook URL for posting updates.
- `MESSAGE_ID`: ID of the message to edit with new embeds.
- `DYNMAP_URL`: Enter Dynmap URL (if applicable).
Expand All @@ -58,19 +59,19 @@ npm start

This will initiate the bot, and it will periodically fetch and update the status of the Minecraft servers on your Discord server. _(Set to 15 minutes by Default)_

## Webhook/Embed Example Images
## Webhook/Embed Example Images _(Icon not included)_

#### Desktop

![desktop](https://raw.githubusercontent.com/NotYourAverageGamer/MCStatus-Bot-for-Discord/main/images/desktop.png)
![desktop](https://raw.githubusercontent.com/NotYourAverageGamer/MCStatus-Bot-for-Discord/main/screenshots/desktop.png)

#### iOS

![ios](https://raw.githubusercontent.com/NotYourAverageGamer/MCStatus-Bot-for-Discord/main/images/ios.png)
![ios](https://raw.githubusercontent.com/NotYourAverageGamer/MCStatus-Bot-for-Discord/main/screenshots/ios.png)

#### Android

![android](https://raw.githubusercontent.com/NotYourAverageGamer/MCStatus-Bot-for-Discord/main/images/android.png)
![android](https://raw.githubusercontent.com/NotYourAverageGamer/MCStatus-Bot-for-Discord/main/screenshots/android.png)

## License

Expand Down
147 changes: 0 additions & 147 deletions bot/main.js

This file was deleted.

86 changes: 0 additions & 86 deletions bot/start-script.js

This file was deleted.

7 changes: 7 additions & 0 deletions config/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SERVER_NAME="YOUR_SERVER_NAME"
JAVA_API_URL="YOUR_JAVA_API_URL"
BEDROCK_API_URL="YOUR_BEDROCK_API_URL"
WEBHOOK_URL="YOUR_WEBHOOK_URL"
MESSAGE_ID="YOUR_MESSAGE_ID"
DYNMAP_URL="YOUR_DYNMAP_URL"
THUMBNAIL_URL="YOUR_THUMBNAIL_URL"
6 changes: 0 additions & 6 deletions example.env

This file was deleted.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "minecraft-status-bot-discord",
"version": "1.0.0",
"main": "main.js",
"name": "mcstatus-bot-for-discord",
"version": "2.0.0",
"main": "src/bot/main.js",
"scripts": {
"start": "node ./bot/start-script.js"
"start": "node ./src/bot/startScript.js"
},
"author": "NotYourAverageGamer",
"license": "GPL-3.0",
Expand All @@ -13,5 +13,5 @@
"dotenv": "^16.4.5"
},
"keywords": [],
"description": "A MC Server Status Bot for Discord"
"description": "A Minecraft Server Status Bot for Discord"
}
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 7e41465

Please sign in to comment.