DiscordKit: can now get to ready event
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user