discord.js icon indicating copy to clipboard operation
discord.js copied to clipboard

Make Rest manager more decouple

Open H01001000 opened this issue 3 years ago • 4 comments

Which package is the feature request for?

rest

Feature

Currently, the REST manager is directly hard code to discord.js although people can change it, discord,js still install as deps and it is hard for people to separate REST manager to another process. This will be the first step to separate discord.js to a smaller service.

Ideal solution or implementation

There are a few things to do:

  • make an adapter located in each discord and REST's package where it transforms eg this.client.rest.post to a post request and decode HTTP request to rest.post.
  • change client options to DefaultRestOptions or ExternalRestOptions (URL, header, etc)
  • change init client to (something like), when init, the process will like zlib, but it first checks if the rest option is ExternalRestOptions (check is URL exists), if success it uses external rest, if failed, it tries to import rest, if success, it uses rest-client if failed it exit 1

But we need to find a way to deal with DefaultRestOptions, (HTTP,rate limit, discord API) Error import from rest to discord

Extra:

  • if this works we can publish a docker image for the rest manager

Alternative solutions or implementations

While keeping discordjs easy to use (and same it current way) and allowing for microservice use, we can make a new package like discordjs/(core or bot) where it moves all current core logic of discordjs to there and the current discordjs package will like a wapper for linking all other packages, in simply (discordjs -> monolithic/wapper), (discordjs/core -> micro/bot processing part)

Other context

No response

H01001000 avatar Apr 04 '22 17:04 H01001000

Sidenote: can we have a roadmap for discordjs's micro package status

H01001000 avatar Apr 04 '22 17:04 H01001000

I'm confused, what's the issue with @discordjs/rest, which can be used standalone without the main library?

kyranet avatar Apr 04 '22 17:04 kyranet

I think they want to be able to use a different REST library than our /rest in d.js right? (I can think of an use case: global request manager)

Is that so?

vladfrangu avatar Apr 04 '22 18:04 vladfrangu

TLDR completely septate rest manager out from discord.js allows:

  • multiple bot processes use the same rest manager (for example non-discordjs bot can also use the rest manager to send messages)
  • use other rest managers
  • mockclient (in further, where we can feed mock message directly to bot (when ws package is done) and get the response from the bot directly)

I think its more like discord.js but in a way it relates to rest, so I put in rest for now

H01001000 avatar Apr 04 '22 18:04 H01001000