discord / discord-api-docs

Official Discord API Documentation
https://discord.com/developers/docs/intro
Other
5.98k stars 1.27k forks source link

Document IPC api #1704

Open applebee1558 opened 4 years ago

applebee1558 commented 4 years ago

Currently, the IPC api is in use by the GameSDK, but is not mentioned at all in the API docs. The console messages from the client show that the GameSDK uses the IPC api. On the discord API docs, only the deprecated RPC api is documented. The GameSDK is awesome, but I think letting people interact with the IPC api would be better.

Hacksore commented 2 years ago

Additional things that would be helpful to document for RPC, if possible.

Hacksore commented 1 month ago

Today I learned that if you connect via the WebSocket transport you will not get the user object in the READY response.

Perhaps this is by design but as of today it's not documented that applications should use the IPC transport when referring to the published RPC documentation.

This means the docs are misleading to think we should expect the user object to be returned if using a WebSocket transport.

WebSocket

{
  "cmd": "DISPATCH",
  "data": {
    "v": 1,
    "config": {
      "cdn_host": "cdn.discordapp.com",
      "api_endpoint": " //discord.com/api",
      "environment": "production"
    }
  },
  "evt": "READY",
  "nonce": null
}

IPC

{
  "cmd": "DISPATCH",
  "data": {
    "v": 1,
    "config": {
      "cdn_host": "cdn.discordapp.com",
      "api_endpoint": "//discord.com/api",
      "environment": "production"
    },
    "user": {
      "id": "378293909610037252",
      "username": "hacksore",
      "discriminator": "0",
      "global_name": "Hacksore",
      "avatar": "fc3de7c170c64aea332da5b03cff5853",
      "avatar_decoration_data": null,
      "bot": false,
      "flags": 4194592,
      "premium_type": 2
    }
  },
  "evt": "READY",
  "nonce": null
}

related: https://github.com/overlayeddev/overlayed/issues/171

applebee1558 commented 1 month ago

Today I learned that if you connect via the WebSocket transport you will not get the user object in the READY response.

Perhaps this is by design but as of today it's not documented that applications should use the IPC transport when referring to the published RPC documentation.

This means the docs are misleading to think we should expect the user object to be returned if using a WebSocket transport.

WebSocket

{
  "cmd": "DISPATCH",
  "data": {
    "v": 1,
    "config": {
      "cdn_host": "cdn.discordapp.com",
      "api_endpoint": " //discord.com/api",
      "environment": "production"
    }
  },
  "evt": "READY",
  "nonce": null
}

IPC

{
  "cmd": "DISPATCH",
  "data": {
    "v": 1,
    "config": {
      "cdn_host": "cdn.discordapp.com",
      "api_endpoint": "//discord.com/api",
      "environment": "production"
    },
    "user": {
      "id": "378293909610037252",
      "username": "hacksore",
      "discriminator": "0",
      "global_name": "Hacksore",
      "avatar": "fc3de7c170c64aea332da5b03cff5853",
      "avatar_decoration_data": null,
      "bot": false,
      "flags": 4194592,
      "premium_type": 2
    }
  },
  "evt": "READY",
  "nonce": null
}

related: overlayeddev/overlayed#171

I believe it’s probably because the Websocket RPC API is technically accessible to any website. However I highly doubt either APIs would ever get documented fully or taken out of beta providing that discord is completely shifting away from games and also deprecating the gamesdk and store that worked pretty well before.

TwilightZebby commented 1 month ago

providing that discord is completely shifting away from games

FYI: As of May 2024, Discord switched back to focusing on games, as per the blog post by their CEO.

Hacksore commented 1 month ago

I believe it’s probably because the Websocket RPC API is technically accessible to any website.

You can try to connect from any website but the RPC server has strict origin checks so if you are not connecting from an allowed rpc_origin you'll get a INVALID_ORIGIN = 4008 error.

Maybe there is something else I'm not accounting for 🤔.