question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scheduled Events serializer is broken

See original GitHub issue

using 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:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
NikkyAIcommented, Feb 2, 2022

works flawlessly, only doing external events, so the rest i have not tested

0reactions
Lukellmanncommented, Feb 1, 2022

The fix is merged, does it work now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django Serializer with Websockets not working due to request ...
I am trying to use a websockets to send a queryset to my frontend using a model serializer. When I test this out...
Read more >
Solved: Event Serialization Not Working
Solved: Hi all, I'm trying to serialize an event, transactions actually, and whenever I set the eventID the event isn't passed in the...
Read more >
Binary serialization is broken when building against ... - GitHub
To use the OnSerializingAttribute, the method must contain a StreamingContext parameter. We are currently hitting this issue on the System.
Read more >
BinaryFormatter serialization methods are obsolete and ...
Serialize and Deserialize methods on BinaryFormatter, Formatter, and IFormatter are now obsolete as warning. Additionally, BinaryFormatter  ...
Read more >
3.0 Announcement - Django REST framework
It comprehensively addresses some of the previous remaining design issues in serializers, fields and the generic views. This release is incremental in nature....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found