Skip to content

Releases: DiscordBM/DiscordBM

1.10.1 - Use `HTTPClient.shared` as default + Simplify README

12 Apr 16:44
ddce0d0
Compare
Choose a tag to compare

What's Changed

  • Use HTTPClient.shared and HTTPClient.shared.eventLoopGroup as default HTTPClient and EventLoopGroup in #68
  • Fix a bug when mixing PartialUser with DiscordUser which could result in removing author of a DiscordUser.

Full Changelog: v1.10.0...1.10.1

v1.10.0 - Introducing `UnstableEnum` macro - UPDATE RECOMMENDED

04 Feb 18:25
Compare
Choose a tag to compare

What's Changed

  • @UnstableEnum macro for enums that will have more cases over time in #52

Discussion

This version introduces a UnstableEnum macro:

  • The macro makes every raw-representable enum that it's assigned to more resilient.
  • All enums with this macro have a new case called __undocumented(RawValue).
    • Adding enum cases is allowed based on DiscordBM's policy mentioned in the README, so this is not considered a "Breaking Change" by DiscordBM.
  • If Discord introduces a new enum value (which is pretty common), the macro will save the undocumented value in the __undocumented case.
  • Usage of __undocumented is discouraged as it's not considered part of DiscordBM's API and can cause code breakage.
    • If DiscordBM adds the proper enum case for an __undocumented value, codes that count on __undocumented will stop working after a DiscordBM update. Extra caution needs needs to be taken.
  • In normal Swift, an undocumented enum value will make the whole decoding process fail, which is catastrophic.
    • Imagine receiving a massive GUILD_CREATE event, but the event fails to decode only because one enum cannot be decoded, and your code stops working properly.
  • DiscordBM had some Codable hacks in place which mitigated the damage caused by this behavior, but now these decoding failures will be a thing of the past.
  • Updating to this version of DiscordBM is HIGHLY RECOMMENDED to make sure you don't face silent decoding failures which can cause bugs in your applications.

This version drops support for Swift 5.7 and 5.8. This due to the macro usage which requires Swift 5.9.

Full Changelog: v1.9.1...v1.10.0

v1.9.1 - Minor fixes

27 Jan 19:07
0b14cfc
Compare
Choose a tag to compare

What's Changed

  • Repair an api-breakage by Discord, occasionally sending Activity.application_id of type Int.
  • Fix a build failure in WebSocket tests.

Full Changelog: v1.9.0...v1.9.1

v1.9.0

27 Jan 16:10
5c04595
Compare
Choose a tag to compare

What's Changed

  • Add 43 and 44 Permissions in #63
    • 43 is createGuildExpressions.
    • 44 is createEvents.
  • Add require functions for Interaction.Data in #64
    • requireApplicationCommand()
    • requireMessageComponent()
    • requireModalSubmit()

Full Changelog: v1.8.0...v1.9.0

v1.8.0 - Minor updates

30 Dec 12:26
Compare
Choose a tag to compare

What's Changed

  • Add applied_tags to execute-webhook payload in #61
  • Temporary fix for a decoding error (Would have not been a problem if i could merge this PR :( )

Full Changelog: v1.7.0...v1.8.0

v1.7.0 - `GatewayManager` use `events` instead of `makeEventsStream()`

05 Nov 18:25
Compare
Choose a tag to compare

What's Changed

  • GatewayManager move to using events instead of makeEventsStream()
    Previously you would do:
for await event in await bot.makeEventsStream() {
   /// Do something with `event`
}

Now you do:

for await event in await bot.events {
   /// Do something with `event`
}

For most users, this is only a change to nicer names.
But in fact, the AsyncSequence of bot.events is of type DiscordAsyncSequence which enables DiscordBM to change the underlying implementation to something more-optimized in the future, if needs be.

Decoding Fixes

Some decoding failures have been resolved.

For example Discord silently changed Guild.Member.joined_at to be nullable, which resulted in some decode failures.
DiscordBM will now set Guild.Member.joined_at to Date.distantFuture if no value is provided by Discord.
This prevents DiscordBM breaking its public API due to Discord changes, by marking Guild.Member.joined_at as Optional.

Also some AuditLog.Entry decode failures have been resolved.

Full Changelog: v1.6.0...v1.7.0

v1.6.0 - GatewayEventHandler functions can throw now

02 Nov 06:23
7758d76
Compare
Choose a tag to compare

GatewayEventHandler functions can throw too now, so you don't have to use an explicit do/catch.
Upon a thrown error, the GatewayEventHandler will log the error while including the function name which threw the error.

The README has been updated to reflect this. As an example:

struct EventHandler: GatewayEventHandler {
    let event: Gateway.Event
    let client: any DiscordClient

    func onMessageCreate(_ payload: Gateway.MessageCreate) async throws {
        let response = try await client.createMessage(
            channelId: payload.channel_id,
            payload: .init(content: "Got a message: '\(payload.content)'")
        )

        let message = try response.decode()
    }
}

The function can now be marked as throws.

This previously needed a do/catch:

struct EventHandler: GatewayEventHandler {
    let event: Gateway.Event
    let client: any DiscordClient

    func onMessageCreate(_ payload: Gateway.MessageCreate) async {
        do {
            let response = try await client.createMessage(
                channelId: payload.channel_id,
                payload: .init(content: "Got a message: '\(payload.content)'")
            )

            let message = try response.decode()
        } catch {
            print("We got an error! \(error)")
        }
    }
}

Full Changelog: v1.5.0...v1.6.0

v1.5.0 - Support monetization APIs + update with Discord changes

29 Oct 21:53
d12398a
Compare
Choose a tag to compare

Update with Discord docs till October 28 2023

  • AuditLog.Entry.Action.memberRoleUpdate(integration_type: Integration.Kind) now is (integration_type: Integration.Kind?). The type of integration_type has been changed to be Optional.
    • This is technically a breaking change, but considering that i deemed it low-impact, and a workaround would have been troublesome, i proceeded with the change.
  • 3 new Gateway events:
    • entitlementCreate(Entitlement)
    • entitlementUpdate(Entitlement)
    • entitlementDelete(Entitlement)
  • 5 new DiscordClient endpoints:
    • updateOwnApplication(payload:)
    • listEntitlements(appId:userId:skuIds:before:after:limit:guildId:excludeEnded:)
    • createTestEntitlement(appId:payload:)
    • deleteTestEntitlement(appId:entitlementId:)
    • listSKUs(appId:)
  • DiscordCache stores entitlements now.
  • Interaction now contains the entitlements.
  • You can create premiumRequired() as a InteractionResponse.
  • JSONErrorCode has 2 new cases:
    • anEntitlementHasAlreadyBeenGrantedForThisResource
    • invalidSKU
  • Other minor changes. See full change log below for more info.

Full Changelog: v1.4.0...v1.5.0

v1.4.0 - Some Fixes, DiscordBM Swift 5.9 release delayed

24 Sep 18:18
a949bd5
Compare
Choose a tag to compare

DiscordBM release to move to requiring Swift 5.9 has been delayed as i need to workaround some macro issues first.
The release might be delayed up to when Swift 5.9.1 is released.

What's Changed

  • Fix bot.updatePresence(payload:) by @codemeister64 in #57
  • Rename/deprecate startThreadInForumChannel to startThreadInForumOrMediaChannel.
    • The response contains the returned message too now.

New Contributors

Full Changelog: v1.3.1...v1.4.0

v1.3.1 - Next release will require Swift 5.9+

18 Sep 20:36
Compare
Choose a tag to compare

Next release will require Swift 5.9+

Next release will make heavy use of macros to for a decent amount of better user experience as well as some performance boosts.
I have decided the library will not support Swift versions lower than 5.9 as soon as the macro is merged.

What's Changed

  • Increase default backoff maxAllowed from 5 to 6 seconds.
    • I have a personal feeling from my experience that a 6s maxAllowed will be decently better in practice, as 5s is exactly the age of a bucket and a second more could help users not notice rate-limit problems even less.
  • Some other minor refinements such as more documentation.

Full Changelog: v1.3.0...v1.3.1