Files
zunda-bot/Sources/DiscordKit/Bot.swift
2026-03-22 13:15:54 -04:00

24 lines
627 B
Swift

import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
public actor Bot {
public let client: ApiClient
let gateway: GatewayClient
public init(token: String, intents: Intents) async throws {
client = ApiClient(token: token)
let gatewayURL = try await client.getGatewayURL()
gateway = GatewayClient(gatewayURL: gatewayURL, token: token, intents: intents)
}
public func connect() async throws {
try await gateway.openConnection()
}
public var events: AsyncStream<GatewayPayload> {
get async { await gateway.events }
}
}