Skip to content

Bots and Applications

Spacebar is compatible with Discord.com, and so all existing bots and applications designed for Discord.com should work relatively easily when connected to a Spacebar instance instead.

Bot Libraries

Below are some popular libraries for connecting bots to a Spacebar instance.

Make sure to replace api.spacebar.chat and cdn.spacebar.chat with the appropriate URLs of the instance you want to connect to.

You can get them from a client or from the well-known instance endpoint.

Discord.js

The Client class constructor accepts a http object, which you can use to change the endpoints used.

const { Client } = require("discord.js");

const client = new Client({
    rest: {
        api: "https://api.spacebar.chat/api",
        cdn: "https://cdn.spacebar.chat",
        version: "9"
    },
    ws: {
        version: 9
    },
    // intents, ...
});

client.login("your token here");

Discord.py

import discord

discord.http.Route.BASE = "https://api.spacebar.chat/api"
client = discord.Client()

client.run("your token here")

JDA

  1. Create a RestConfig instance: RestConfig restConfig = new RestConfig();
  2. Use RestConfig#setBaseUrl to tell JDA what your Rest URI is: restConfig.setBaseUrl("https://api.spacebar.chat/api/v9");
  3. Create another class, and extend ConcurrentSessionController, e.g. public class SpacebarSessionController extends ConcurrentSessionController
  4. Override the ConcurrentSessionController#getGateway method:
        @NotNull
        @Override
        public String getGateway() {
            return "wss://{REPLACE HERE WITH YOUR GATEWAY SERVER URL}/?encoding=json&v=9&compress=zlib-stream";
        }
    
  5. Finally, configure JDA to use your RestConfig & SpacebarSessionController, like this:
    JDA jda = JDABuilder.createDefault("your token here")
                    .setRestConfig(restConfig)
                    .setSessionController(new SpacebarSessionController())
                    .build();