Releases: DiscordBM/DiscordBM
v1.12.0 - MISC additions and refinements
What's Changed
Message
types now containcall
info.Gateway.MessageReactionAdd
now containsburst_colors
.User
types now containavatar_decoration_data
.Interaction
might containguild
info.ModifyCurrentUser
acceptsbanner
too.DiscordClient.listMessageReactionsByEmoji()
supports specifying reactiontype
.DiscordClient.followAnnouncementChannel()
supports specifyingreason
.DiscordClient.getCDNUserAvatarDecoration()
is deprecated. UsegetCDNAvatarDecoration()
instead.AuditLog.Entry
now supports someonboarding
andhomeSettings
actions.- Relax SwiftSyntax version requirement (#74)
Full Changelog: v1.11.0...v1.12.0
v1.11.0 - User Installable Apps, Polls, One Time Purchase SKUs, and more
User Installable Apps
User Installable Apps are "In Preview" by Discord. As Implemented through this commit, DiscordBM doesn't provide stable API for them.
Use @_spi(UserInstallableApps) import DiscordModels
to access this feature:
import DiscordBM
@_spi(UserInstallableApps) import DiscordModels
For a full list of the changes, have a look at Discord's Change Log.
See this tutorial for more info about User Installable Apps.
Polls
See Discord's Documentation for a list of the additions.
The feature is implemented in DiscordBM through this commit.
One Time Purchase SKUs
One Time Purchase SKUs are implemented in DiscordBM through this commit.
See the Change Log for a list of the changes.
"Technically Breaking" changes
Most of these changes are not breaking per DiscordBM's policy which is mentioned in the README which allows DiscordBM to evolve and implement new Discord features in minor versions without a lot of trouble.
- All "Endpoint" enums now have an additional case to explicitly discourage exhaustive switch statements:
__DO_NOT_USE_THIS_CASE
. Entitlement.Kind
was not marked with@UnstableEnum
, now it is.Entitlement
'sconsumed: Bool
has been changed toconsumed: Bool?
to match Discord's documentation.
Other changes
DefaultDiscordClient
's default retry behavior has changed to retry requests up to 3 times (from 1) and also retry responses withGateway Timeout
status codes.- Add
bulkBanUsersFromGuild
endpoint. - [Swift 6 Compatibility] Move
LosslessRawRepresentable
out ofUnstableEnum
macro target in #69 - Support for
enforce_nonce
increateMessage()
endpoint function. - Allow
suppressNotifications
flag in validations of inexecuteWebhook()
endpoint functions. - Fix
Gateway.Intent.unprivileged
which used to work the other way around and only return privileged intents. - DiscordBM reports the OS in use more accurately to Discord.
- Less fatal errors.
Full Changelog: 1.10.1...v1.11.0
1.10.1 - Use `HTTPClient.shared` as default + Simplify README
What's Changed
- Use
HTTPClient.shared
andHTTPClient.shared.eventLoopGroup
as defaultHTTPClient
andEventLoopGroup
in #68 - Fix a bug when mixing
PartialUser
withDiscordUser
which could result in removingauthor
of aDiscordUser
.
Full Changelog: v1.10.0...1.10.1
v1.10.0 - Introducing `UnstableEnum` macro - UPDATE RECOMMENDED
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" byDiscordBM
.
- Adding enum cases is allowed based on
- 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 ofDiscordBM
'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 aDiscordBM
update. Extra caution needs needs to be taken.
- If
- 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.
- Imagine receiving a massive
DiscordBM
had someCodable
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
What's Changed
- Repair an api-breakage by Discord, occasionally sending
Activity.application_id
of typeInt
. - Fix a build failure in WebSocket tests.
Full Changelog: v1.9.0...v1.9.1
v1.9.0
v1.8.0 - Minor updates
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()`
What's Changed
GatewayManager
move to usingevents
instead ofmakeEventsStream()
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
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
Update with Discord docs till October 28 2023
AuditLog.Entry.Action.memberRoleUpdate(integration_type: Integration.Kind)
now is(integration_type: Integration.Kind?)
. The type ofintegration_type
has been changed to beOptional
.- 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
storesentitlements
now.Interaction
now contains theentitlements
.- You can create
premiumRequired()
as aInteractionResponse
. 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