admin管理员组

文章数量:1390410

Before you read the question, I would like to inform you that I'm not intrested in mand cooldown thing and this question is not connected to it.

Since my friend server got raided about 30 times last week I stared wondering about writing a bot in js using discord.js v12...


But...
I couldn't find a way to get over Discord rate limit. By that I mean so if the action of the bot is rejected bcs of rate limit the bot will wait for those 5 seconds and would go again with the action.

So, let me explain it a little further with an example:
20 raiders started spamming with pings etc. bot detected that but after few bans meets the rate limit, and since we don't want to just spam discord API and keep receiving messages about rate limiting I wonder if we could slow it down a little so the bot would ban 1 pearson from those 20 per second or get info how much do we need to wait after receiving rate limit message and resuming actions after the time we had to wait
Yeah I know that this may be quite slow but at least will work...

Sorry for over plicating this a little ^-^"

Before you read the question, I would like to inform you that I'm not intrested in mand cooldown thing and this question is not connected to it.

Since my friend server got raided about 30 times last week I stared wondering about writing a bot in js using discord.js v12...


But...
I couldn't find a way to get over Discord rate limit. By that I mean so if the action of the bot is rejected bcs of rate limit the bot will wait for those 5 seconds and would go again with the action.

So, let me explain it a little further with an example:
20 raiders started spamming with pings etc. bot detected that but after few bans meets the rate limit, and since we don't want to just spam discord API and keep receiving messages about rate limiting I wonder if we could slow it down a little so the bot would ban 1 pearson from those 20 per second or get info how much do we need to wait after receiving rate limit message and resuming actions after the time we had to wait
Yeah I know that this may be quite slow but at least will work...

Sorry for over plicating this a little ^-^"

Share Improve this question edited Feb 8, 2021 at 1:46 Hakunek asked Feb 8, 2021 at 1:39 HakunekHakunek 231 silver badge6 bronze badges 1
  • If you're looking for general rate limits you could ask in the Discord API official server. However, you should focus on better server security to prevent such raids. Otherwise just set up a bot that will take in manual input to ban 1 member at a time. – Elitezen Commented Feb 8, 2021 at 2:24
Add a ment  | 

1 Answer 1

Reset to default 4

I don't have a turnkey solution for you, but here are some resources to check out that could help you:

  • https://discord.js/#/docs/main/v12/class/Client?scrollTo=e-rateLimit

  • https://discord./developers/docs/topics/rate-limits

Rate limits are dynamic, hence the "rateLimit" event of the library could be of use to you.

However, I had the notion discord.js natively handled rate limits by queuing actions accordingly (see here), so I'm unsure you have to handle this by yourself.

By the way, useful resources if you are a beginner with discord.js: https://discordjs.guide/

PS: You could also step up the verification level of your server. It probably would be both more easy and effective.

本文标签: javascriptDiscordjs Rate Limit DelayStack Overflow