Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Use precondition(), set sharding as let
Browse files Browse the repository at this point in the history
  • Loading branch information
Defxult committed Oct 8, 2023
1 parent 5f2a332 commit 12c7448
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Sources/Discord/Discord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class Bot {
public internal(set) var cachedMessages = Set<Message>()

/// Whether automatic sharding is enabled. If your bot is in 2500 or more guilds, this *must* be enabled.
public internal(set) var sharding: Bool
public let sharding: Bool

/// The global allowed mentions.
public static var allowedMentions = AllowedMentions.default
Expand Down Expand Up @@ -611,7 +611,7 @@ public struct CacheManager {
/// Has all caching capabilities enabled and a max message cache size of 1,500.
public static let `default` = CacheManager(messages: 1500, users: true, members: true)

/// Has `users` and `members` caching capabilities enabled and a max message cache size of 500.
/// Has `users` caching capabilities disabled and a max message cache size of 500.
public static let limited = CacheManager(messages: 500, users: false, members: true)

/// Has all caching capabilities disabled and a max message cache size of 100.
Expand Down
6 changes: 2 additions & 4 deletions Sources/Discord/Http.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1708,15 +1708,13 @@ class HTTPClient {
}

static func buildEndpoint(_ path: APIRoute, endpoint: String) -> String {
guard endpoint.starts(with: "/") else {
fatalError("Endpoint must start with /")
}
precondition(endpoint.starts(with: "/"), "Endpoint must start with /")
return path.rawValue + endpoint
}

/// Creates the full HTTP endpoint.
private func route(_ url: String, route: APIRoute = .base) -> String {
guard url.starts(with: "/") else { fatalError("URL route must begin with /") }
precondition(url.starts(with: "/"), "URL route must begin with /")
return route.rawValue + url
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Discord/Models/Guild.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ public class Guild : Object, Hashable, Updateable {
return try await bot!.http.getGuildTemplates(guildId: id)
}

/// Updates the properties of the guild when received via gateway event`GUILD_UPDATE`.
/// Updates the properties of the guild when received via gateway event `GUILD_UPDATE` and possibly `GUILD_CREATE`.
func update(_ data: JSON) {
for (k, v) in data {
switch k {
Expand Down

0 comments on commit 12c7448

Please sign in to comment.