Interface CatnipHook


public interface CatnipHook
A horrible thing that allows you to patch JSON objects and other stuff. This is a horrible idea, but it exists mainly to allow you to hackpatch in things that can't be added / won't be added / just aren't currently in the library. Methods on this class are called SYNCHRONOUSLY, and so any implementations of it should take this into consideration.

For example, if you had a message-caching extension, you could use this to inject the cached data into MESSAGE_UPDATE events, to make the data in the event actually be "complete."

Again, this is a TERRIBLE idea. You should only use this if you have absolutely no other choice. It is highly recommended that you try to find an alternative to using this.

Since:
10/7/18.
Author:
amy
  • Method Details

    • rawGatewayReceiveHook

      default com.grack.nanojson.JsonObject rawGatewayReceiveHook(@Nonnull ShardInfo shardInfo, @Nonnull com.grack.nanojson.JsonObject json)
      Called when a payload is received over the websocket. The default behaviour is an identify function.
      Parameters:
      json - The incoming JSON data.
      Returns:
      A possibly-edited gateway-sent JSON payload.
    • rawGatewaySendHook

      default com.grack.nanojson.JsonObject rawGatewaySendHook(@Nonnull ShardInfo shardInfo, @Nonnull com.grack.nanojson.JsonObject json)
      Called when a payload is sent over the websocket. The default behaviour is an identify function.
      Parameters:
      json - The outgoing JSON data.
      Returns:
      A possibly-edited gateway-sent JSON payload.
    • rawGatewayOpenHook

      default void rawGatewayOpenHook(@Nonnull ShardInfo shard)
      Called when the websocket is opened. The default behaviour is to do nothing.
      Parameters:
      shard - The shard of the socket.
    • rawGatewayCloseHook

      default void rawGatewayCloseHook(@Nonnull ShardInfo shard, int code, @Nonnull String reason)
      Called when the websocket is closed. The default behaviour is to do nothing.
      Parameters:
      shard - The shard of the socket.
      code - The close code.
      reason - The reason for closing.
    • rawRestReceiveDataHook

      default ResponsePayload rawRestReceiveDataHook(@Nonnull Routes.Route route, @Nonnull ResponsePayload response)
      Called when a payload is received in a REST request response. Note that, due to how the Discord API works, it is possible that the data received may be empty. The default behaviour is an identity function.

      THIS METHOD DOES NOT SUPPORT CHANGING THE ROUTE.

      Parameters:
      response - The incoming data.
      Returns:
      A possibly-edited REST-response payload.
    • rawRestSendObjectHook

      default com.grack.nanojson.JsonObject rawRestSendObjectHook(@Nonnull Routes.Route route, @Nullable com.grack.nanojson.JsonObject json)
      Called when a payload is about to be sent in a REST request response. Note that, due to how the Discord API works, it is possible that the data received may be empty. The default behaviour is an identity function.

      THIS METHOD DOES NOT SUPPORT CHANGING THE ROUTE.

      Parameters:
      json - The outgoing JSON data.
      Returns:
      A possibly-edited REST-response JSON payload.