Skip to content

Commit

Permalink
Small fixes based on Discord messages:
Browse files Browse the repository at this point in the history
- Nullable field in GuildJoinRequest
- Better error handling for event handlers
  • Loading branch information
gdude2002 committed Jan 14, 2025
1 parent 3a0d0ca commit 12b83cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,18 @@ public open class ExtensibleBot(
* @param handler The event handler to be registered.
* @throws EventHandlerRegistrationException Thrown if the event handler could not be registered.
*/
@Suppress("TooGenericExceptionCaught")
@Throws(EventHandlerRegistrationException::class)
public inline fun <reified T : Event> registerListenerForHandler(handler: EventHandler<T>): Job {
return on<T>(scope = handler.coroutineScope) {
handler.call(this)
try {
handler.call(this)
} catch (e: Exception) {
logger.error(e) {
"Exception thrown by event handler in '${handler.extension.name}' extension - " +
"Event type is ${T::class.simpleName} (from ${T::class.java.packageName}); handler is $handler"
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public data class GuildJoinRequest(
public val status: ApplicationStatus,

@SerialName("form_responses")
public val formResponses: List<GuildJoinRequestResponse>,
public val formResponses: List<GuildJoinRequestResponse>?,

@SerialName("actioned_by_user")
public val actionedByUser: DiscordUser? = null,
Expand Down

0 comments on commit 12b83cb

Please sign in to comment.