First thanks for a superb project, really made writing my bot easy.
However, I'm getting an exception on some GUILD_CREATE messages at startup as follows:
Exception in thread "DefaultDispatcher-worker-3" java.lang.IllegalStateException: Expected class kotlinx.serialization.json.JsonObject but found class kotlinx.serialization.json.JsonLiteral
at kotlinx.serialization.json.internal.AbstractJsonTreeInput.beginStructure(TreeJsonInput.kt:183)
at com.jessecorbett.diskord.api.model.Role$$serializer.deserialize(Role.kt)
at com.jessecorbett.diskord.api.model.Role$$serializer.deserialize(Role.kt:7)
at kotlinx.serialization.Decoder$DefaultImpls.decodeSerializableValue(Coders.kt:113)
// ...
at kotlinx.serialization.TaggedDecoder.tagBlock(Tagged.kt:267)
at kotlinx.serialization.TaggedDecoder.decodeNullableSerializableElement(Tagged.kt:257)
at com.jessecorbett.diskord.api.model.Emoji$$serializer.deserialize(Emoji.kt)
at com.jessecorbett.diskord.api.model.Emoji$$serializer.deserialize(Emoji.kt:8)
// ...
{
"roles": [
"471093321251422218"
],
"require_colons": false,
"name": "pajama3StayWild",
"managed": true,
"id": "568952139779670048",
"animated": false
}
class EmojisTest {
@Test
fun `check emoji with roles`() {
val json = String(this::class.java.getResource("/emoji-with-role.json").readBytes())
val emoji = Json.nonstrict.parse(Emoji.serializer(), json)
Assertions.assertThat(emoji).isNotNull
}
@Test
fun `check emoji without roles`() {
val json = String(this::class.java.getResource("/emoji-empty-roles.json").readBytes())
val emoji = Json.nonstrict.parse(Emoji.serializer(), json)
Assertions.assertThat(emoji).isNotNull
}
}
which when provided with an empty list for the roles field passes, but the non-empty role is failing (the string value doesn't match com.jessecorbett.diskord.api.model.Emoji).
I think this is ultimately the cause of the initial error I'm getting.