Deploying the Discord Go template

A comprehensive guide to deploying the Discord Go Template to a production environment. This ensures your bot is usable 24/7.

🚀 Prerequisites

Before deploying the Go Uploader Template to production, ensure you have the following ready:

  • A VPS or server to host the uploader (e.g., DigitalOcean, AWS, or any hosting provider) with root or sudo access.

  • Go (version 1.23 or higher) installed on your vps/server You can install it using:

    sudo apt update
    sudo apt install golang
    

📦 Installation

1. Clone the Repository

Download the template from GitHub to your server:

git clone https://github.com/ResyncedDesign/DiscordGoBot
cd DiscordGoBot

2. Configure the Environment

The template uses a .env file to manage sensitive settings.

  1. Copy the .env.example file to `.env:
cp .env.example .env
  1. Fill out the .env with your Discord Bot Token, Client ID, and Guild ID:
TOKEN=YOUR_DISCORD_BOT_TOKEN
CLIENTID=YOUR_DISCORD_CLIENT_ID
GUILDID=YOUR_DISCORD_GUILD_ID

3. Test the Application

Run the application to ensure it works as expected and there are no errors:

go run main.go

If everything is working as expected, you can proceed to the next step.

4. Build the Application

Build the application to create a binary file that can be run on your server:

go build -o bot main.go

5. Set up Systemd

Systemd is a system and service manager for Linux operating systems. It is used to manage services and daemons. You can create a systemd service file to manage your Discord Go Template.

  1. Create a new service file:

    sudo nano /etc/systemd/system/discord.service
    
  2. Add the following configuration to the file:

    [Unit]
    Description=Resynced Discord Bot
    After=network.target
    
    [Service]
    ExecStart=/path/to/DiscordGoBot/bot
    WorkingDirectory=/path/to/DiscordGoBot/
    Restart=always
    User=your-username
    
    [Install]
    WantedBy=multi-user.target
    
  3. Save and close the file.

  4. Start and enable the service:

    sudo systemctl daemon-reload
    sudo systemctl start discord
    sudo systemctl enable discord
    
  5. Check the status of the service to ensure it is running without any errors:

    sudo systemctl status discord
    

Your Discord Go Template is now deployed and running on your server. You can access the bot on Discord and start using it in your server.