import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

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)
    }

    public func connect() async throws {
        try await gateway.openConnection(intents: intents)
    }

    public var events: AsyncStream<GatewayMessage> {
        get async { await gateway.events }
    }
}
