Files
zunda-bot/Sources/DiscordKit/Bot.swift

26 lines
674 B
Swift

import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
public actor Bot {
let client: ApiClient
let gateway: GatewayClient
let intents: Intents
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)
}
public func connect() async throws {
try await gateway.openConnection(intents: intents)
}
public var events: AsyncStream<GatewayMessage> {
get async { await gateway.events }
}
}