Coder Social home page Coder Social logo

discord-json's Introduction

discord-json

Maven Central GitHub Workflow Status (branch)

Discord entity domain now available as immutable Jackson objects. Building this project requires JDK 11.

discord-json's People

Contributors

alex1304 avatar azn9 avatar bytealex avatar cottoncammy avatar darichey avatar doc94 avatar dominoxp avatar gregory-widmer avatar j0rdanit0 avatar latvianmodder avatar lukellmann avatar masterzach32 avatar novafox161 avatar quanticc avatar redstoneguy129 avatar rfresh2 avatar shadorc avatar simonit avatar skykatik avatar thenumberone avatar undermybrella avatar waujito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

discord-json's Issues

Review method naming

Things like:

GuildMemberAdd::guild instead of guildId
GuildMemberRemove::guild instead of guildId
also GuildBanAdd, GuildBanRemove, GuildEmojisUpdate, GuildIntegrationsUpdate

Error when deserializing audit log response

Running this code:

        memberLeaveEvent.getClient().rest().getAuditLogService()
                .getAuditLog(memberLeaveEvent.getGuildId().asLong(), Collections.emptyMap())
                .subscribe(auditLog -> {
                        logger.info("auditLog={}", auditLog);
                });

resulted in this error:

09:33:35.777 [boundedElastic-2] ERROR reactor.core.publisher.Operators - Operator called default onErrorDropped
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of `discord4j.discordjson.json.ImmutableIntegrationData`, problem: Cannot build IntegrationData, some of required attributes are not set [enabled]
 at [Source: (byte[])"{"audit_log_entries": [{"id": "********", "user_id": "********", "target_id": "********", "action_type": 20}, {"id": "********", "user_id": "********", "target_id": "********", "action_type": 28}, {"id": "********", "user_id": "********", "target_id": "********", "action_type": 80, "changes": [{"key": "type", "new_value": "discord"}]}, {"id": "********", "user_id": "********", "target_id""[truncated 18582 bytes]; line: 1, column: 12685] (through reference chain: discord4j.discordjson.json.ImmutableAuditLogData$Json["integrations"]->java.util.ArrayList[0])
Caused by: java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of `discord4j.discordjson.json.ImmutableIntegrationData`, problem: Cannot build IntegrationData, some of required attributes are not set [enabled]
 at [Source: (byte[])"{"audit_log_entries": [{"id": "********", "user_id": "********", "target_id": "********", "action_type": 20}, {"id": "********", "user_id": "********", "target_id": "********", "action_type": 28}, {"id": "********", "user_id": "929066667387011104", "target_id": "********", "action_type": 80, "changes": [{"key": "type", "new_value": "discord"}]}, {"id": "********", "user_id": "********", "target_id""[truncated 18582 bytes]; line: 1, column: 12685] (through reference chain: discord4j.discordjson.json.ImmutableAuditLogData$Json["integrations"]->java.util.ArrayList[0])
	at discord4j.rest.http.JacksonReaderStrategy.lambda$read$0(JacksonReaderStrategy.java:74)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	*__checkpoint ⇢ Body from GET /guilds/930254044868542484/audit-logs [ClientResponse]
Original Stack Trace:
		at discord4j.rest.http.JacksonReaderStrategy.lambda$read$0(JacksonReaderStrategy.java:74)
		at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:106)
		at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:119)
		at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854)
		at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854)
		at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854)
		at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:220)
		at reactor.core.publisher.FluxDoFinally$DoFinallySubscriber.onNext(FluxDoFinally.java:130)
		at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:184)
		at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107)
		at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
		at reactor.core.publisher.MonoCollectList$MonoCollectListSubscriber.onComplete(MonoCollectList.java:128)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260)
		at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:142)
		at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:400)
		at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:419)
		at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:473)
		at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:702)
		at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
		at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
		at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
		at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)
		at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299)
		at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
		at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1372)
		at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1235)
		at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1284)
		at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:510)
		at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:449)
		at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
		at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
		at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
		at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
		at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
		at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
		at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
		at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
		at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
		at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
		at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
		at java.base/java.lang.Thread.run(Thread.java:833)

Error while decoding JSON

I always see logs with problem deserualizes, for example

2023-02-25 01:01:31.538  WARN 552124 [discord4j.gateway.payload.JacksonPayloadReader] : Error while decoding JSON (java.lang.IllegalArgumentException: Attempt to deserialize payload with unknown event type: GUILD_AUDIT_LOG_ENTRY_CREATE): {"t":"GUILD_AUDIT_LOG_ENTRY_CREATE","s":7,"op":0,"d":{"user_id":"1074931195487473694","target_id":"1078844157818322984","reason":"create from site","id":"1078844157818322985","changes":[{"new_value":"Juggernaut-Dota 2","key":"name"},{"new_value":2,"key":"type"},{"new_value":64000,"key":"bitrate"},{"new_value":3,"key":"user_limit"},{"new_value":[{"type":0,"id":"1042150011422658750","deny":"1024","allow":"0"},{"type":0,"id":"1042369124422135858","deny":"1024","allow":"0"}],"key":"permission_overwrites"},{"new_value":false,"key":"nsfw"},{"new_value":0,"key":"rate_limit_per_user"},{"new_value":0,"key":"flags"}],"action_type":10,"guild_id":"1042150011422658750"}}


2023-02-25 01:01:31.945  WARN 552124 [discord4j.gateway.payload.JacksonPayloadReader] : Error while decoding JSON (java.lang.IllegalArgumentException: Attempt to deserialize payload with unknown event type: GUILD_AUDIT_LOG_ENTRY_CREATE): {"t":"GUILD_AUDIT_LOG_ENTRY_CREATE","s":9,"op":0,"d":{"user_id":"1074931195487473694","target_id":null,"id":"1078844160083234886","changes":[{"new_value":"GVChz6VYgp","key":"code"},{"new_value":"1078844157818322984","key":"channel_id"},{"new_value":"1074931195487473694","key":"inviter_id"},{"new_value":0,"key":"uses"},{"new_value":0,"key":"max_uses"},{"new_value":0,"key":"max_age"},{"new_value":false,"key":"temporary"}],"action_type":40,"guild_id":"1042150011422658750"}}

Error when deserialize `GatewayData` in graalvm#native-image runtime-mode

Produce

use graalvm native-image compile the application which builtin discord4j dep.

Question

It will delegate on ImmutableGatewayData#fromJson, and try to consturct instance of the Json.
As i know, the ImmutableGatewayData$Json was non-public inner-class, so append on reflect-config.json <init> was not working.

{
    "name": "discord4j.discordjson.json.ImmutableGatewayData",
    "allDeclaredConstructors": true,
    "allDeclaredFields": true,
    "methods": [
      {
        "name": "isSessionStartLimitPresent",
        "parameterTypes": [ ]
      },
      {
        "name": "sessionStartLimit",
        "parameterTypes": [ ]
      },
      {
        "name": "fromJson",
        "parameterTypes": [
          "discord4j.discordjson.json.ImmutableGatewayData$Json"
        ]
      },
      {
        "name": "isShardsPresent",
        "parameterTypes": [ ]
      },
      {
        "name": "url",
        "parameterTypes": [ ]
      },
      {
        "name": "shards",
        "parameterTypes": [ ]
      }
    ]
  }

Exception

Caused by: java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `discord4j.discordjson.json.ImmutableGatewayData$Json`: cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized
 at [Source: (byte[])"{"url": "wss://gateway.discord.gg", "session_start_limit": {"max_concurrency": 1, "remaining": 988, "reset_after": 28846008, "total": 1000}, "shards": 1}"; line: 1, column: 2]
        at discord4j.rest.http.JacksonReaderStrategy.lambda$read$0(JacksonReaderStrategy.java:74) ~[na:na]
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
        *__checkpoint ⇢ Body from GET /gateway/bot [ClientResponse]
Original Stack Trace:
                at discord4j.rest.http.JacksonReaderStrategy.lambda$read$0(JacksonReaderStrategy.java:74) ~[na:na]
                at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:106) ~[na:na]
                at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:128) ~[na:na]

Error when decoding ChannelPinsUpdate

Error while decoding JSON (com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of discord4j.discordjson.json.gateway.ImmutableChannelPinsUpdate, problem: Cannot build ChannelPinsUpdate, some of required attributes are not set [lastPinTimestamp]
at [Source: UNKNOWN; line: -1, column: -1]): {"t":"CHANNEL_PINS_UPDATE","s":4137,"op":0,"d":{"last_pin_timestamp":null,"channel_id":"12345","guild_id":"12345"}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.