Scheduled Events serializer is broken
See original GitHub issueusing kord-extension 1.5.2-SNAPSHOT and kord 0.8.x-SNAPSHOT
when trying to list scheduled events:
2022-01-31 00:54:44.880 ERROR com.kotlindiscord.kord.extensions.commands.application.slash.SlashCommand : Error during execution of list slash command (dev.kord.core.event.interaction.GuildChatInputCommandInteractionCreateEvent@6054ac99)
kotlinx.serialization.MissingFieldException: Fields [channelId, user_count] are required for type with serial name 'dev.kord.common.entity.DiscordGuildScheduledEvent', but they were missing
at kotlinx.serialization.internal.PluginExceptionsKt.throwMissingFieldException(PluginExceptions.kt:20)
at dev.kord.common.entity.DiscordGuildScheduledEvent.<init>(DiscordGuildScheduledEvent.kt:34)
at dev.kord.common.entity.DiscordGuildScheduledEvent$$serializer.deserialize(DiscordGuildScheduledEvent.kt:34)
at dev.kord.common.entity.DiscordGuildScheduledEvent$$serializer.deserialize(DiscordGuildScheduledEvent.kt:34)
at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:59)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:36)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:535)
code:
val messages = guild.scheduledEvents.toList().map { event ->
"""
description: ${event.description}
start: ${event.scheduledStartTime}
end: ${event.scheduledEndTime}
status: ${event.status}
type: ${event.entityType}
type: ${event.entityMetadata}
data: ${event.data}
""".trimIndent()
}
when trying to create a scheduled event:
2022-01-31 01:14:52.623 ERROR com.kotlindiscord.kord.extensions.commands.application.slash.SlashCommand : Error during execution of create slash command (dev.kord.core.event.interaction.GuildChatInputCommandInteractionCreateEvent@41b0d135) dev.kord.rest.request.KtorRequestException: REST request returned an error: 400 Bad Request Invalid Form Body {“entity_metadata”:{“location”:{“_errors”:[{“_errors”:[{“code”:“BASE_TYPE_REQUIRED”,“message”:“This field is required”}]}]}}} at dev.kord.rest.request.KtorRequestHandler.handle(KtorRequestHandler.kt:62) at dev.kord.rest.request.KtorRequestHandler$handle$1.invokeSuspend(KtorRequestHandler.kt)
code:
private suspend fun updateSchedule(
guild: Guild,
startTime: Instant,
name: String,
description: String? = null,
duration: Duration = 1.hours,
) {
guild.createScheduledEvent(
name = name,
privacyLevel = StageInstancePrivacyLevel.GuildOnly,
scheduledStartTime = startTime, //Clock.System.now() + 10.minutes,
entityType = ScheduledEntityType.External
) {
description?.let {
this.description = it
}
scheduledEndTime = startTime + duration
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
works flawlessly, only doing external events, so the rest i have not tested
The fix is merged, does it work now?