improved disconnection logic (hopefully)

This commit is contained in:
2026-03-25 16:58:39 -04:00
parent eff450e898
commit a1ed1564b9
3 changed files with 49 additions and 32 deletions

View File

@@ -47,10 +47,11 @@ public struct SessionStartLimit: Codable, Sendable {
public let max_concurrency: Int
}
public enum GatewayPayload: Decodable, Sendable {
public enum GatewayPayload: Decodable, Sendable, Equatable {
case hello(GatewayHello)
case messageCreate(MessageCreate)
case ready(GatewayReady)
case heartbeatAck
}
public struct GatewayMessage: Decodable, Sendable {
@@ -72,6 +73,8 @@ public struct GatewayMessage: Decodable, Sendable {
s = try container.decode(Int?.self, forKey: .s)
t = try container.decode(String?.self, forKey: .t)
switch op {
case 11:
d = .heartbeatAck
case 10:
let hello = try container.decode(GatewayHello.self, forKey: .d)
d = .hello(hello)
@@ -95,12 +98,12 @@ public struct GatewayMessage: Decodable, Sendable {
}
}
public struct GatewayReady: Codable, Sendable {
public struct GatewayReady: Codable, Sendable, Equatable {
public let session_id: String
public let resume_gateway_url: URL
}
public struct GatewayHello: Codable, Sendable {
public struct GatewayHello: Codable, Sendable, Equatable {
public let heartbeat_interval: Int
}
@@ -172,7 +175,7 @@ public struct MessageRefrence: Codable, Sendable {
let guild_id: String?
}
public struct MessageCreate: Codable, Sendable {
public struct MessageCreate: Codable, Sendable, Equatable {
public let id: String
public let channel_id: String
public let guild_id: String?
@@ -183,19 +186,19 @@ public struct MessageCreate: Codable, Sendable {
}
public struct User: Codable, Sendable {
public struct User: Codable, Sendable, Equatable {
public let id: String?
public let bot: Bool?
public let global_name: String?
public let username: String
}
public struct GuildMember: Codable, Sendable {
public struct GuildMember: Codable, Sendable, Equatable {
public let user: User?
public let nick: String?
}
public struct MentionUser: Codable, Sendable {
public struct MentionUser: Codable, Sendable, Equatable {
public let id: String?
public let bot: Bool?
public let global_name: String?