1
0
mirror of https://github.com/spacebarchat/docs.git synced 2024-11-08 19:32:30 +01:00

Merge pull request #86 from ripples1253/master

This commit is contained in:
Madeline 2024-04-03 11:49:13 +11:00 committed by GitHub
commit 9da58ff96b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,21 +41,21 @@ client.run('your token here')
``` ```
### JDA ### JDA
1. Create a RestConfig instance: `RestConfig restConfig = new RestConfig();`
2. Use RestConfig#setBaseUrl to tell JDA what your Rest URI is (this NEEDS to include /api/<apiver>, because it's the api **base** url for all requests): `restConfig.setBaseUrl("https://{REPLACE HERE WITH YOUR API SERVER URL}/api/v9");`
3. Create another class, and extend ConcurrentSessionController, e.g. `public class SpacebarSessionController extends ConcurrentSessionController`
4. Override the ConcurrentSessionController#getGateway method:
```java ```java
import java.lang.reflect.*; @NotNull
import net.dv8tion.jda.internal.requests.*; @Override
public String getGateway() {
public static void main(String[] args) { return "wss://{REPLACE HERE WITH YOUR GATEWAY SERVER URL}/?encoding=json&v=9&compress=zlib-stream";
JDA jda = JDABuilder.createDefault("your token here").build(); }
```
Field field = Requester.class.getDeclaredField("DISCORD_API_PREFIX") 5. Finally, configure JDA to use your RestConfig & SpacebarSessionController, like this:
field.setAccessible(true); ```java
JDA jda = JDABuilder.createDefault("not_a_real_token_lol")
Field modifiers = Field.class.getDeclaredField("modifiers"); .setRestConfig(restConfig)
modifiers.setAccessible(true); .setSessionController(new SpacebarSessionController())
modifiers.setString(field, field.getModifiers() & ~Modifier.FINAL); .build();
field.set(null, "https://api.{{ project.domain }}");
}
``` ```