kashifulhaque / discord-bot-for-gcp

A Discord Bot to provision GCP Compute Engine instance. 🤖
MIT License
12 stars 2 forks source link
api discord discord-bot discord-js discordjs gcp gcp-compute gcp-compute-engine google-api google-cloud google-cloud-apis google-cloud-platform json minecraft minecraft-server yarn

Discord Bot for GCP Compute Engine

A Discord bot which uses the Google Cloud API to provision a Compute Engine instance.

Story time


My friend and I, we love playing Minecraft. What we don't like is going through the painful process of starting a server via the GCP console. So, I went ahead and built this Discord bot to automate that process.

• Typing in !server status gives the current status of the server.

• Typing in !server start starts the GCP Compute Engine instance. Typing in !server start again returns the Compute Engine instance external IP address, afaik the Google Cloud API does not send a response when the server gets started so you have to manually call the API again. You can use a timer also to automate it partially.

• Typing in !server stop stops the GCP Compute Engine instance.

Ok, how do I host my own bot?

  1. Make sure you have Node.js installed. You can download it here
  2. Install yarn [OPTIONAL]
  3. Clone this repo using git clone https://github.com/kashifulhaque/discord-bot-for-gcp.git command.
  4. Move into the repo directory using cd discord-bot-for-gcp command
  5. Create a new Discord App via it's Developer portal
  6. Make sure to enable the bot and copy it's token. DO NOT REVEAL THE TOKEN TO ANYONE.
  7. Also generate the Bot invite link while you are there. Tell me how
  8. Rename dummy-discord-config.json to discord-config.json and open the file. Paste the token in the required place.
  9. Visit the GCP Auth Docs and follow the steps there to generate a service account and the Auth key. A JSON file will be downloaded containing all the keys and tokens required. AGAIN, DO NOT SHARE THIS WITH ANYONE.
  10. Replace the dummy-GCP_config.json with the JSON file you downloaded.
  11. Type in npm install or yarn install [If you have yarn installed] to get all the required dependencies.
  12. Type in npm start or yarn start [If you have yarn installed] to start the Discord bot

If you face any problems, feel free to create an Issue from the Issues tab. I will try to respond as early as possible.