Skip to content

novicezk/discord-websocket-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discord-websocket-client

使用Authorization连接discord的websocket,能够监听所有的相关消息

使用说明

  1. 进入discord频道,打开network,刷新页面,找到 messages 的请求
  2. Authorization 即 userToken,User-Agent 即 userAgent User Token
  3. 引入maven依赖
<dependency>
    <groupId>io.github.novicezk</groupId>
    <artifactId>discord-websocket-client</artifactId>
    <version>1.0</version>
</dependency>
  1. 启动websocket
String userToken = "xxx";
String userAgent = "xxx";
MessageListener messageListener = new MessageListener() {
    @Override
    public void onMessage(JSONObject message) throws Exception {
		System.out.println(message);
	}

    @Override
    public void onClose(int code, String reason) {
		System.out.println("Closed! code: " + code + ", reason: " + reason);
	}
};
UserWebSocketClient client = new UserWebSocketClient(Compression.ZLIB, userToken, messageListener);
client.setUserAgent(userAgent);
try {
    client.connect();
} catch (WebSocketClientStartException e) {
    e.printStackTrace();
}

About

使用Authorization连接discord的websocket

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages