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

add ability to use HTTPOptions/AgentOptions for ShardingManager to use for fetchRecommendedShards

Open unek opened this issue 3 years ago • 5 comments

Feature

since cloudflare is being a dick sometimes and bans my bot's IP (error code: 1015, basically 429 too many requests) I have to change my bot's network interface sometimes. while I can do that for my Clients (by setting client.options.http.agent.localAddress) I cannot select which network interface is used for fetching the recommended amount of shards (through fetchRecommendedShards) when sharding.

Ideal solution or implementation

a good option would be to add an HTTPOptions or AgentOptions like setting to ShardingManagerOptions, similar to what ClientOptions has. of course I can use a pre-set amount of shards (totalShards) which prevents ShardingManager from making any requests to discord.com over the default network interface, but that seems like a less than ideal solution.

Alternative solutions or implementations

No response

Other context

No response

unek avatar Nov 30 '21 11:11 unek

Why does cloudfare block your requests, any abusing things you are doing?

A easy solution would be, to install node fetch, add the http agent and doing the request manually.

meister03 avatar Dec 02 '21 21:12 meister03

my bot is just very very very popular in short bursts. we usually hit discord's global rate limits thousands times a day before we run into any issues with cloudflare. discord knows this issue and offers rate limit increase for popular bots.

unek avatar Dec 02 '21 21:12 unek

my bot is just very very very popular in short bursts. we usually hit discord's global rate limits thousands times a day before we run into any issues with cloudflare. discord knows this issue and offers rate limit increase for popular bots.

Can you tell me the guilds count for your bot and what kind of bot is exactly?

itsmishra19 avatar Feb 10 '22 19:02 itsmishra19

Can you tell me the guilds count for your bot and what kind of bot is exactly?

30,000 guilds roughly, and it's a bot with a lot of people clicking buttons

unek avatar Feb 10 '22 19:02 unek

Can you tell me the guilds count for your bot and what kind of bot is exactly?

30,000 guilds roughly, and it's a bot with a lot of people clicking buttons

Do you get ratelimited while user clicking a lot of buttons or on any other route?

itsmishra19 avatar Feb 10 '22 19:02 itsmishra19

You should be able to accomplish this as of v14 by just setting the undici dispatcher the REST instance uses using ClientOptions#rest#agent or Client#rest#setAgent.

didinele avatar Nov 02 '22 11:11 didinele