DiscordKit: can now get to ready event

This commit is contained in:
2026-03-17 16:37:31 -04:00
parent 29a2b0370b
commit 7506a06d7f
6 changed files with 139 additions and 39 deletions

View File

@@ -3,15 +3,23 @@ import Foundation
import FoundationNetworking
#endif
public struct Bot {
public actor Bot {
let client: ApiClient
let gateway: GatewayClient
let intents: Intents
public init(token: String) async throws {
public init(token: String, intents: Intents) async throws {
client = ApiClient(token: token)
self.intents = intents
let gatewayURL = try await client.getGatewayURL()
gateway = GatewayClient(gatewayURL: gatewayURL, token: token)
}
let gateway = GatewayClient(gatewayURL: gatewayURL)
try await gateway.openConnection()
public func connect() async throws {
try await gateway.openConnection(intents: intents)
}
public var events: AsyncStream<GatewayMessage> {
get async { await gateway.events }
}
}