Giter Club home page Giter Club logo

embed-generator's Introduction

Embed Generator

Release Docker image

Release MIT License Discord Server

A powerful tool for creating rich-embed Discord messages using webhooks.

You will usually want to use the hosted version at https://message.style. There is not much benefit in hosting this yourself.

YouTube tutorial

Youtube Tutorial

Self Hosting

This describes the easiest way to self host an instance of Embed Generator by creating a single binary that contains both the backend and frontend.

You can find prebuilt binaries of the server with the frontend files included here.

Configure the server

To configure the server you can create a file called config.yaml with the following fields:

discord:
  client_id: ""
  client_secret: ""
  token: ""

openai:
  api_key: "" # for ChatGPT integration (optional)

postgres:
  host: "localhost"
  port: 5432
  dbname: "embedg"
  user: "postgres"
  password: ""

app:
  public_url: "http://localhost:5173/app"

api:
  # Make sure to add {public_url}/auth/callback to the OAuth2 Redirect URLs of your application in the Discord dev portal
  public_url: "http://localhost:5173/api"

  host: "localhost"
  port: 8080

# These links are used in help commands and for redirects
links:
  discord: https://discord.gg/CpHwbKQKHA
  source: https://github.com/merlinfuchs/embed-generator

log:
  use_json: false # Enable to this to have easily parsable JSON log messages (you usually don't want this)

# Here you can configure multiple tiers/plans which are linked to a Discord SKU
premium:
  plans:
    # The default plan that all users automatically have
    - id: default
      default: true
      features:
        max_saved_messages: 25
        max_actions_per_component: 2
        advanced_action_types: false
        ai_assistant: false
        is_premium: false
        custom_bot: false
        max_custom_commands: 0
        max_scheduled_messages: 5
        periodic_scheduled_messages: false
    # An additional premium plan that will apply when the user or guild has the SKU
    - id: premium_server
      sku_id: "123"
      features:
        max_saved_messages: 100
        max_actions_per_component: 5
        advanced_action_types: true
        ai_assistant: true
        is_premium: true # This is used for handing out cosmetics like a role on the support server
        custom_bot: true
        max_custom_commands: 5
        max_scheduled_messages: 10
        periodic_scheduled_messages: true

You can also set the config values using environment variables. For example EMBEDG_DISCORD__TOKEN will set the discord token.

Using Docker (docker-compose)

Install Docker and docker-compose and create a docker-compose.yaml file with the following contents:

version: "3.8"

services:
  postgres:
    image: postgres
    restart: always
    volumes:
      - embedg-local-postgres:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: postgres
      POSTGRES_DB: embedg
      PGDATA: /var/lib/postgresql/data/pgdata
      POSTGRES_HOST_AUTH_METHOD: trust
    healthcheck:
      test: ["CMD", "pg_isready"]
      interval: 30s
      timeout: 30s
      retries: 3

  minio:
    image: quay.io/minio/minio
    command: server --console-address ":9001" /data
    ports:
      - "9000:9000"
      - "9001:9001"
    environment:
      MINIO_ROOT_USER: embedg
      MINIO_ROOT_PASSWORD: 1234567890
    volumes:
      - embedg-local-minio:/data

  embedg:
    image: merlintor/embed-generator:latest
    restart: always
    ports:
      - "8080:8080"
    environment:
      - EMBEDG_API__HOST=0.0.0.0
      - EMBEDG_POSTGRES__HOST=postgres
      - EMBEDG_POSTGRES__USER=postgres
      - EMBEDG_POSTGRES__DB=embedg
      - EMBEDG_S3__ENDPOINT=minio:9000
      - EMBEDG_API__PUBLIC_URL=http://localhost:8080/api
      - EMBEDG_APP__PUBLIC_URL=http://localhost:8080/app
    volumes:
      - ./config.yaml:/root/config.yaml

volumes:
  embedg-local-postgres:
  embedg-local-minio:

Run the file using docker-compose up. It will automatically mount the config.yaml file into the container. You should not configure postgres in your config file as it's using the postgres instance from the container.

Embed Generator should now be accessible in your browser at http://localhost:8080.

Build from source

Build the app

You can download NodeJS and NPM from nodejs.org.

# Switch to the embedg-app directory
cd embedg-app

# Install yarn globally
npm install -g yarn

# Install dependencies
yarn install

# Start the development server (optional)
yarn dev

# Build for production use
yarn build

Build the site (home page & docs)

# Switch to the embedg-app directory
cd embedg-site

# Install yarn globally
npm install -g yarn

# Install dependencies
yarn install

# Start the development server (optional)
yarn start

# Build for production use
yarn build

Build the server (backend)

Install Go >=1.21 from go.dev.

# Switch to the backend directory
cd embedg-server
# or if you are in the frontend directoy
cd ../embedg-server

# Configure the server (see steps below)

# Run database migrations
go run main.go migrate postgres up

# Start the development server (optional)
go run --tags "embedapp embedsite" main.go server

# Build and include the frontend files in the backend binary (build app and site first)
go build --tags  "embedapp embedsite"

# Build without including the frontend files in the backend binary (you need to serve yourself)
go build

Install databases

If you are not using Docker you need to Install PostgreSQL on your device and create a user and database. I'm sure you can find instructions online!

Run the binary

You should now be able to run the binary and host your own instance of Embed Generator. You usually want to deploy this behind a reverse proxy like Nginx and terminate TLS there.

embed-generator's People

Contributors

merlinfuchs avatar yourlocalanon avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.