feat: Resume after disconnect

This commit is contained in:
Andrew Glaze
2026-03-22 13:14:26 -04:00
parent bc72fc9781
commit e6426225d7
4 changed files with 122 additions and 59 deletions

View File

@@ -6,20 +6,18 @@ import FoundationNetworking
public actor Bot {
public let client: DiscordClient
let gateway: GatewayClient
let intents: Intents
public init(token: String, intents: Intents) async throws {
client = DiscordClient(token: token)
self.intents = intents
let gatewayURL = try await client.getGatewayURL()
gateway = GatewayClient(gatewayURL: gatewayURL, token: token)
gateway = GatewayClient(gatewayURL: gatewayURL, token: token, intents: intents)
}
public func connect() async throws {
try await gateway.openConnection(intents: intents)
try await gateway.openConnection()
}
public var events: AsyncStream<GatewayMessage> {
public var events: AsyncStream<GatewayPayload> {
get async { await gateway.events }
}
}