rename DiscordClient to ApiClient

This commit is contained in:
Andrew Glaze
2026-03-22 13:15:54 -04:00
parent e6426225d7
commit 887f6e46d4
5 changed files with 12 additions and 12 deletions

View File

@@ -3,7 +3,7 @@ import Foundation
import FoundationNetworking
#endif
public struct DiscordClient: Sendable {
public struct ApiClient: Sendable {
static let apiUrl: URL = URL(string: "https://discord.com/api/v10")!
let token: String
@@ -20,7 +20,7 @@ public struct DiscordClient: Sendable {
}
func getGatewayURL() async throws -> URL {
var req = URLRequest(url: DiscordClient.apiUrl.appending(path: "/gateway/bot"))
var req = URLRequest(url: ApiClient.apiUrl.appending(path: "/gateway/bot"))
req.httpMethod = "GET"
let (data, _) = try await authReq(req)
@@ -30,7 +30,7 @@ public struct DiscordClient: Sendable {
}
public func getOwnUser() async throws -> User {
var req = URLRequest(url: DiscordClient.apiUrl.appending(path: "/users/@me"))
var req = URLRequest(url: ApiClient.apiUrl.appending(path: "/users/@me"))
req.httpMethod = "GET"
let (data, _) = try await authReq(req)
@@ -40,7 +40,7 @@ public struct DiscordClient: Sendable {
}
public func createMessage(channelId: String, payload: CreateMessageReq) async throws {
var req = URLRequest(url: DiscordClient.apiUrl.appending(path: "/channels/\(channelId)/messages"))
var req = URLRequest(url: ApiClient.apiUrl.appending(path: "/channels/\(channelId)/messages"))
req.httpMethod = "POST"
let json = JSONEncoder()
@@ -49,7 +49,7 @@ public struct DiscordClient: Sendable {
}
public func triggerTypingIndicator(channelId: String) async throws {
var req = URLRequest(url: DiscordClient.apiUrl.appending(path: "/channels/\(channelId)/typing"))
var req = URLRequest(url: ApiClient.apiUrl.appending(path: "/channels/\(channelId)/typing"))
req.httpMethod = "POST"
try await authReq(req)
}