Files
zunda-bot/Sources/DiscordKit/Bot.swift
2026-03-20 17:53:29 -04:00

26 lines
689 B
Swift

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