Skip to content

Commit

Permalink
patch (folders)!: add id property to GuildFolderItem
Browse files Browse the repository at this point in the history
BREAKING CHANGE: signature of init modified
  • Loading branch information
cryptoAlgorithm committed Sep 8, 2022
1 parent 9bccc3b commit cbf0870
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/DiscordKit/Gateway/DiscordGateway.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class DiscordGateway: ObservableObject {

/// An array of guild folders
@Published public var guildFolders: [GuildFolderItem] = []
@Published public var guildPositions: [Snowflake] = []

private var evtListenerID: EventDispatch.HandlerIdentifier? = nil,
authFailureListenerID: EventDispatch.HandlerIdentifier? = nil,
Expand Down Expand Up @@ -227,6 +226,7 @@ public class DiscordGateway: ObservableObject {
// Update guild folders
guildFolders = settings.guildFolders.folders.map {
.init(
id: $0.hasID ? String($0.id.value) : nil,
name: $0.hasName ? $0.name.value : nil,
guild_ids: $0.guildIds.map({ id in String(id) }),
color: $0.hasColor ? Int($0.color.value) : nil
Expand Down
4 changes: 3 additions & 1 deletion Sources/DiscordKitCommon/Objects/Guild.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,14 @@ public struct GuildScheduledEventEntityMeta: Codable, GatewayData {
///
/// Metadata for a guild folder
public struct GuildFolderItem: Decodable, GatewayData, Equatable {
public init(name: String? = nil, guild_ids: [Snowflake], color: Int? = nil) {
public init(id: Snowflake? = nil, name: String? = nil, guild_ids: [Snowflake], color: Int? = nil) {
self.id = id
self.name = name
self.guild_ids = guild_ids
self.color = color
}

public let id: Snowflake?
public let name: String?
// let id: Int? // Sometimes Discord sends over String snowflakes, but sometimes it sends int snowflakes instead just to make life hard
public let guild_ids: [Snowflake]
Expand Down

0 comments on commit cbf0870

Please sign in to comment.