Releases: DiscordBM/DiscordBM
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
v1.4.0 - Some Fixes, DiscordBM Swift 5.9 release delayed
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
tostartThreadInForumOrMediaChannel
.- The response contains the returned message too now.
New Contributors
- @codemeister64 made their first contribution in #57
Full Changelog: v1.3.1...v1.4.0
v1.3.1 - Next release will require Swift 5.9+
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.
- I have a personal feeling from my experience that a 6s
- Some other minor refinements such as more documentation.
Full Changelog: v1.3.0...v1.3.1