AstralAPI Docs
Libraries

Go

Use discordgo with Astral

discordgo is the de-facto Discord library for Go. It exposes its base URLs through package variables you can override before constructing the session.

go get github.com/bwmarrin/discordgo
package main

import (
	"log"
	"os"

	"github.com/bwmarrin/discordgo"
)

func init() {
	// Repoint REST and Gateway at Astral.
	discordgo.EndpointDiscord = "https://astraof.com/"
	discordgo.EndpointAPI = discordgo.EndpointDiscord + "api/v1/"
}

func main() {
	dg, err := discordgo.New("Bot " + os.Getenv("ASTRAL_BOT_TOKEN"))
	if err != nil {
		log.Fatal(err)
	}

	dg.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) {
		if m.Author.Bot {
			return
		}
		if m.Content == "!ping" {
			s.ChannelMessageSend(m.ChannelID, "pong")
		}
	})

	dg.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsMessageContent

	if err := dg.Open(); err != nil {
		log.Fatal(err)
	}

	select {}
}

Gateway URL is fetched at runtime

discordgo asks the API for the gateway URL via GET /gateway. Because we already repointed EndpointAPI, that request hits Astral and returns the Astral gateway URL — no additional override is needed for the WebSocket endpoint.

Astral API Docs | Go