Skip to content

Commit

Permalink
rename _undocumented to __undocumented
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Jan 28, 2024
1 parent 031affd commit 2cf1f90
Show file tree
Hide file tree
Showing 34 changed files with 150 additions and 151 deletions.
4 changes: 2 additions & 2 deletions Macros/UnstableEnumMacro/+EnumCaseElementSyntax.swift
Expand Up @@ -10,10 +10,10 @@ extension [EnumCaseElementSyntax] {
guard self.count > 0 else { return ([], false) }
var `self` = self
let last = self.removeLast()
guard last.name.trimmedDescription == "_undocumented" else {
guard last.name.trimmedDescription == "__undocumented" else {
let diagnostic = Diagnostic(
node: Syntax(last),
message: MacroError.lastCaseMustBe_undocumented
message: MacroError.lastCaseMustBe__undocumented
)
context.diagnose(diagnostic)
return ([], false)
Expand Down
2 changes: 1 addition & 1 deletion Macros/UnstableEnumMacro/EnumCase/+Decodable.swift
Expand Up @@ -14,7 +14,7 @@ extension [EnumCase] {
let rawValue = try container.decode(\#(raw: rawType.rawValue).self)
self.init(rawValue: rawValue)!
#if DISCORDBM_ENABLE_LOGGING_DURING_DECODE
if case let ._undocumented(rawValue) = self {
if case let .__undocumented(rawValue) = self {
DiscordGlobalConfiguration.makeDecodeLogger("\#(raw: enumIdentifier.trimmedDescription)").warning(
"Found an undocumented rawValue",
metadata: [
Expand Down
2 changes: 1 addition & 1 deletion Macros/UnstableEnumMacro/EnumCase/+init(rawValue).swift
Expand Up @@ -16,7 +16,7 @@ extension [EnumCase] {
switch rawValue {
\#(raw: cases.indented())
default:
self = ._undocumented(rawValue)
self = .__undocumented(rawValue)
}
}
"""#
Expand Down
2 changes: 1 addition & 1 deletion Macros/UnstableEnumMacro/EnumCase/+var rawValue.swift
Expand Up @@ -15,7 +15,7 @@ extension [EnumCase] {
\#(raw: accessLevel)var rawValue: \#(raw: rawType.rawValue) {
switch self {
\#(raw: cases.indented())
case let ._undocumented(rawValue):
case let .__undocumented(rawValue):
return rawValue
}
}
Expand Down
2 changes: 1 addition & 1 deletion Macros/UnstableEnumMacro/MacroError.swift
Expand Up @@ -14,7 +14,7 @@ enum MacroError: String, Error {
case badEnumCaseTrailingTrivia
case badEnumCaseComment
case couldNotFindLocationOfNode
case lastCaseMustBe_undocumented
case lastCaseMustBe__undocumented
}

extension MacroError: DiagnosticMessage {
Expand Down
3 changes: 1 addition & 2 deletions Macros/UnstableEnumMacro/UnstableEnum.swift
Expand Up @@ -17,9 +17,9 @@ import SwiftSyntaxMacros
/// case value12 // 12
/// ```
///
/// Requires you to add a new `.__undocumented(RawValue)` case as the last case.
/// How it manipulates the code:
/// Adds `RawRepresentable` conformance where `RawValue` is the generic argument of the macro.
/// Adds a new `._undocumented(RawValue)` case.
/// which can too easily result in code breakage.
/// If `Decodable`, adds a slightly-modified `init(from:)` initializer.
/// If `CaseIterable`, repairs the `static var allCases` requirement.
Expand Down Expand Up @@ -57,7 +57,6 @@ public struct UnstableEnum: MemberMacro {

if hasError { return [] }


/// Some validations

let values = cases.map(\.value)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -715,7 +715,7 @@ Finally, add `import DiscordBM` to your source code.
## Versioning
`DiscordBM` will try to follow Semantic Versioning 2.0.0, with exceptions:
* To keep `DiscordBM` up to date with Discord API's frequent changes, `DiscordBM` will **add** any new properties to any types in **minor** versions, even if it's technically a breaking change.
* `DiscordBM` tries to minimize the effect of this requirement. For example most enums have an underscored case named `_undocumented` which asks users to use non-exhaustive switch statements, preventing future code-breakages.
* `DiscordBM` tries to minimize the effect of this requirement. For example most enums have an underscored case named `__undocumented` which asks users to use non-exhaustive switch statements, preventing future code-breakages.

## Contribution & Support
* If you need help with anything, ask in [DiscordBM's Discord server](https://discord.gg/kxfs5n7HVE).
Expand Down
2 changes: 1 addition & 1 deletion Sources/DiscordGateway/DiscordCache.swift
Expand Up @@ -829,7 +829,7 @@ public actor DiscordCache {
self.autoModerationExecutions[execution.guild_id, default: []].append(execution)
case let .applicationCommandPermissionsUpdate(update):
self.applicationCommandPermissions[update.id] = update
case ._undocumented:
case .__undocumented:
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/DiscordGateway/GatewayEventHandler.swift
Expand Up @@ -498,7 +498,7 @@ extension GatewayEventHandler {
await withLogging(for: "onAutoModerationActionExecution") {
try await onAutoModerationActionExecution(payload)
}
case ._undocumented:
case .__undocumented:
break
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/DiscordModels/Types/Application Commands.swift
Expand Up @@ -9,7 +9,7 @@ public struct ApplicationCommand: Sendable, Codable {
case chatInput // 1
case user // 2
case message // 3
case _undocumented(UInt)
case __undocumented(UInt)
}

/// https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure
Expand All @@ -29,7 +29,7 @@ public struct ApplicationCommand: Sendable, Codable {
case mentionable // 9
case number // 10
case attachment // 11
case _undocumented(UInt)
case __undocumented(UInt)
}

/// https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure
Expand Down Expand Up @@ -164,7 +164,7 @@ public struct GuildApplicationCommandPermissions: Sendable, Codable {
case role // 1
case user // 2
case channel // 3
case _undocumented(Int)
case __undocumented(Int)
}

public var type: Kind
Expand Down
Expand Up @@ -13,7 +13,7 @@ public struct ApplicationRoleConnectionMetadata: Sendable, Codable, ValidatableP
case dateTimeGreaterThanOrEqual // 6
case booleanEqual // 7
case booleanNotEqual // 8
case _undocumented(Int)
case __undocumented(Int)
}

public var type: Kind
Expand Down
2 changes: 1 addition & 1 deletion Sources/DiscordModels/Types/Application.swift
Expand Up @@ -15,7 +15,7 @@ public struct DiscordApplication: Sendable, Codable {
case gatewayMessageContent // 18
case gatewayMessageContentLimited // 19
case applicationCommandBadge // 23
case _undocumented(UInt)
case __undocumented(UInt)
}

/// https://discord.com/developers/docs/resources/application#install-params-object
Expand Down
16 changes: 8 additions & 8 deletions Sources/DiscordModels/Types/Audit Log.swift
Expand Up @@ -183,7 +183,7 @@ public struct AuditLog: Sendable, Codable {
case autoModerationUserCommunicationDisabled // 145
case creatorMonetizationRequestCreated // 150
case creatorMonetizationTermsAccepted // 151
case _undocumented(Int)
case __undocumented(Int)
}

/// A mix of the below two types.
Expand Down Expand Up @@ -246,7 +246,7 @@ public struct AuditLog: Sendable, Codable {
case autoModerationUserCommunicationDisabled(AutoModerationInfo)
case creatorMonetizationRequestCreated
case creatorMonetizationTermsAccepted
case _undocumented
case __undocumented

public struct OverwriteInfo: Sendable, Codable {

Expand Down Expand Up @@ -515,8 +515,8 @@ public struct AuditLog: Sendable, Codable {
self = .autoModerationUserCommunicationDisabled(moderationInfo)
case .creatorMonetizationRequestCreated: self = .creatorMonetizationRequestCreated
case .creatorMonetizationTermsAccepted: self = .creatorMonetizationTermsAccepted
case ._undocumented:
self = ._undocumented
case .__undocumented:
self = .__undocumented
}
}

Expand Down Expand Up @@ -614,7 +614,7 @@ public struct AuditLog: Sendable, Codable {
try container.encode(moderationInfo, forKey: .options)
case .creatorMonetizationRequestCreated: break
case .creatorMonetizationTermsAccepted: break
case ._undocumented: break
case .__undocumented: break
}
}
}
Expand Down Expand Up @@ -651,7 +651,7 @@ public struct AuditLog: Sendable, Codable {
}

public func encode(to encoder: any Encoder) throws {
if case ._undocumented = action { return }
if case .__undocumented = action { return }

var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.guild_id, forKey: .guild_id)
Expand Down Expand Up @@ -736,8 +736,8 @@ extension AuditLog.Entry.ActionKind {
self = .creatorMonetizationTermsAccepted
case .creatorMonetizationRequestCreated:
self = .creatorMonetizationRequestCreated
case ._undocumented:
self = ._undocumented(-1)
case .__undocumented:
self = .__undocumented(-1)
}
}
}
6 changes: 3 additions & 3 deletions Sources/DiscordModels/Types/Auto Moderation.swift
Expand Up @@ -6,7 +6,7 @@ public struct AutoModerationRule: Sendable, Codable {
@UnstableEnum<Int>
public enum EventKind: Sendable, Codable {
case messageSend // 1
case _undocumented(Int)
case __undocumented(Int)
}

/// https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types
Expand All @@ -16,7 +16,7 @@ public struct AutoModerationRule: Sendable, Codable {
case spam // 3
case keywordPreset // 4
case mentionSpam // 5
case _undocumented(Int)
case __undocumented(Int)
}

/// https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata
Expand All @@ -28,7 +28,7 @@ public struct AutoModerationRule: Sendable, Codable {
case profanity // 1
case sexualContent // 2
case slurs // 3
case _undocumented(Int)
case __undocumented(Int)
}

public var keyword_filter: [String]?
Expand Down
30 changes: 15 additions & 15 deletions Sources/DiscordModels/Types/Channel.swift
Expand Up @@ -20,7 +20,7 @@ public struct DiscordChannel: Sendable, Codable {
case guildStageVoice // 13
case guildDirectory // 14
case guildForum // 15
case _undocumented(Int)
case __undocumented(Int)
}

/// https://discord.com/developers/docs/resources/channel#overwrite-object
Expand All @@ -31,7 +31,7 @@ public struct DiscordChannel: Sendable, Codable {
public enum Kind: Sendable, Codable {
case role // 0
case member // 1
case _undocumented(Int)
case __undocumented(Int)
}

public var id: AnySnowflake
Expand All @@ -45,7 +45,7 @@ public struct DiscordChannel: Sendable, Codable {
public enum SortOrder: Sendable, Codable {
case latestActivity // 0
case creationDate // 1
case _undocumented(Int)
case __undocumented(Int)
}

/// https://discord.com/developers/docs/resources/channel#channel-object-forum-layout-types
Expand All @@ -54,23 +54,23 @@ public struct DiscordChannel: Sendable, Codable {
case notSet // 0
case listView // 1
case galleryView // 2
case _undocumented(Int)
case __undocumented(Int)
}

/// https://discord.com/developers/docs/resources/channel#channel-object-channel-flags
@UnstableEnum<UInt>
public enum Flag: Sendable {
case pinned // 1
case requireTag // 4
case _undocumented(UInt)
case __undocumented(UInt)
}

/// https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes
@UnstableEnum<Int>
public enum VideoQualityMode: Sendable, Codable {
case auto // 1
case full // 2
case _undocumented(Int)
case __undocumented(Int)
}

/// Not exactly documented, but they do mention these times in a few different places.
Expand All @@ -82,7 +82,7 @@ public struct DiscordChannel: Sendable, Codable {
case oneDay // 1_440
case threeDays // 4_320
case sevenDays // 10_080
case _undocumented(Int)
case __undocumented(Int)
}

/// https://discord.com/developers/docs/resources/channel#default-reaction-object-default-reaction-structure
Expand Down Expand Up @@ -208,7 +208,7 @@ extension DiscordChannel {
case stageSpeaker // 29
case stageTopic // 31
case guildApplicationPremiumSubscription // 32
case _undocumented(Int)
case __undocumented(Int)
}

/// https://discord.com/developers/docs/resources/channel#message-object-message-flags
Expand All @@ -225,7 +225,7 @@ extension DiscordChannel {
case failedToMentionSomeRolesInThread // 8
case suppressNotifications // 12
case isVoiceMessage // 13
case _undocumented(UInt)
case __undocumented(UInt)
}

/// https://discord.com/developers/docs/resources/channel#channel-mention-object
Expand All @@ -243,7 +243,7 @@ extension DiscordChannel {
@UnstableEnum<UInt>
public enum Flag: Sendable {
case isRemix // 2
case _undocumented(UInt)
case __undocumented(UInt)
}

public var id: AttachmentSnowflake
Expand Down Expand Up @@ -349,7 +349,7 @@ extension DiscordChannel {
case spectate // 2
case listen // 3
case joinRequest // 5
case _undocumented(Int)
case __undocumented(Int)
}

public var type: Kind
Expand Down Expand Up @@ -487,7 +487,7 @@ public enum ThreadKind: Sendable, Codable {
case announcementThread // 10
case publicThread // 11
case privateThread // 12
case _undocumented(Int)
case __undocumented(Int)
}

extension DiscordChannel {
Expand All @@ -500,7 +500,7 @@ extension DiscordChannel {
case roles
case users
case everyone
case _undocumented(String)
case __undocumented(String)
}

public var parse: [Kind]
Expand All @@ -523,7 +523,7 @@ public struct Embed: Sendable, Codable, ValidatablePayload {
case article // "article"
case link // "link"
case autoModerationMessage // "auto_moderation_message"
case _undocumented(String)
case __undocumented(String)
}

public enum DynamicURL: Sendable, Codable, ExpressibleByStringLiteral {
Expand Down Expand Up @@ -708,7 +708,7 @@ extension DiscordChannel.Message.Kind {
return true
case .recipientAdd, .recipientRemove, .call, .channelNameChange, .channelIconChange, .guildDiscoveryDisqualified, .guildDiscoveryRequalified, .guildDiscoveryGracePeriodInitialWarning, .guildDiscoveryGracePeriodFinalWarning, .threadStarterMessage, .guildApplicationPremiumSubscription:
return false
case ._undocumented: return false
case .__undocumented: return false
}
}
}
2 changes: 1 addition & 1 deletion Sources/DiscordModels/Types/Error Codes.swift
Expand Up @@ -243,7 +243,7 @@ public enum JSONErrorCode: Sendable, Codable {
case messageBlockedByHarmfulLinksFilter // 240000
case cannotEnableOnboardingRequirementsAreNotMet // 350000
case cannotUpdateOnboardingWhileBelowRequirements // 350001
case _undocumented(Int)
case __undocumented(Int)
}

/// https://discord.com/developers/docs/topics/opcodes-and-status-codes#json
Expand Down

0 comments on commit 2cf1f90

Please sign in to comment.