Skip to content

refactor(*): update RPC #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed

Conversation

NotSugden
Copy link

@NotSugden NotSugden commented Sep 16, 2020

This PR removes and changes alot of the RPC functions as they have been (presumably) removed, or the API has changed (docs reference)

resolves #71
resolves #76

This is most definetly a semver: major change, version has been bumped to 4.0.0
This PR will be a draft for the time being, there are still some things that need tweaking slightly

A full list of changes

  • Version bumped to 4.0.0
  • Added typings
    • Added typescript^4.0.2 as a dev-dependency
  • Added/Updated all JSDoc documentation
  • Changed RPCClient#accessToken to non-enurmerable
  • Added RPCClient#config as a private object
    • Added RPCClient#apiURL as a public getter
    • Added RPCClient#cdnURL as a public getter
  • Refactored RPCClient#fetch
    • It is no longer set in the constructor
    • The path parameter has been changed to longer require a leading /
    • It is now an async function
  • Refactored RPCClient#connect
    • Gave it a general refactor
    • Added a capital C to the closed connection error
  • Changed parmeter names of RPCClient#request
    • cmd to command
    • evt to event
  • Added private method RPCClient#_onRpcClose to handle rpc close
  • Refactored RPCClient#_onRpcMessage
    • Destructured the message parameter
  • Removed RPCClient#_subscriptions
    • Removed in favour of a better subscription handler
  • Refactored RPCClient#authorize
    • Re-ordered destructured parameters
  • Refactored RPCClient#authorize to be an async function
  • Refactored all RPCClient#get* functions to be async
    • Refactored getChannel, getChannels, getGuild, getUser to use new Channel, and Guild structures respectively
  • Added new structures
    • Guild
    • Channel
    • User
    • UserFlags
    • ClientApplication
  • Refactored some functions to have no return value (void) and be async
    • RPCClient#setCertifiedDevices
    • RPCClient#setActivity
    • RPCClient#clearActivity
    • RPCClient#sendJoinInvite
  • RPCClient#closeJoinRequest
  • Removed RPCClient#sendJoinRequest as it doesn't seem to be documented anymore - not sure on that so if someone could confirm that
  • Refactored RPCClient#setUserVoiceSettings to use less lines
  • Refactored RPCClient#select* to be async and use the new Channel structure
    • RPCClient#selectTextChannel no longer has a force parameter, as its no longer effected
    • RPCClient#selectTextChannel no longer takes an object as its second parameter
  • RPCClient#getVoiceSettings and RPCClient#setVoiceSettings use a private function to resolve the data returned by the RPC API
  • Refactored RPCClient#captureShortcut
    • Now returns a promise which resolves with the first parameter to the callback function passed in the callback!
      • A bit funky I know, perhaps this needs another refactor?
  • Refactored RPCClient#setActivity (general refactor)
  • Removed undocumented (possibly removed?) functions
    • RPCClient#createLobby
    • RPCClient#updateLobby
    • RPCClient#deleteLobby
    • RPCClient#connectToLobby
    • RPCClient#sendToLobby
    • RPCClient#disconnectFromLobby
    • RPCClient#getLobbyMember
    • RPCClient#getRelationships
  • Refactored RPCClient#subscribe
    • No longer uses RPCClient#_subscriptions and instead attaches an event listener
    • All events now emit its RPCEvent on the client
    • Returns a function to unsubscribe, rather than object with a single key unsubscrbibe
    • Is now async
  • RPCClient#destroy is no longer async
  • Removed undocumented events and commands from Constants (see diff for full list)
    • Re-ordered events and commands alphabetically
  • Added API_BASE_URL, CDN_URL, UserFlags, and ChannelTypes into constants
  • Removed undocumented RPC Errors codes and re-organized them
  • Removed now-unused constants
    • LobbyTypes
    • RelationshipTypes
  • Changed IPCTransport to emit an error on the client if it encounters an (what would've been) an unhandled promise rejection
  • Removed the 2nd parameter for new Websocket(...) in WebSocketTransport, intellisense showed that it wasnt the correct type? can't test this due to whitelist-only feature
  • Updated test
    • Renamed test to rpc.js
    • General refactor

Copy link

@papaia papaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@devsnek
Copy link
Member

devsnek commented Sep 16, 2020

You need to separate this into multiple PRs. Also remove the TS stuff, I won't maintain it. Use the @types system instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants