Rate Limit

is it possible to retrieve the header returned when the bot is being rate limited by discord when sending messages? according to https://discord.com/developers/docs/topics/rate-limits
X-RateLimit-Limit: 5
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1470173023
X-RateLimit-Reset-After: 1
X-RateLimit-Bucket: abcd1234
X-RateLimit-Limit: 5
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1470173023
X-RateLimit-Reset-After: 1
X-RateLimit-Bucket: abcd1234
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
9 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
grass
grass11mo ago
djs handles reatelimits for you
meow
meow11mo ago
like if I were to spam messages, the bot will still be able to send them successfully without any error?
grass
grass11mo ago
itd queue them but dont spam the api
meow
meow11mo ago
how
grass
grass11mo ago
djs does it for you
meow
meow11mo ago
So I was planning on doing something like suppose after sending 10 messages the bot gets rate limited and I fetch the X-RateLimit-Reset-After parameter and setTimeout to that many seconds then start sending message again. Is that the right way to do it? I was planning on making a bot that sends DMs to all members in the server is there any way to avoid a rate limit?
d.js docs
d.js docs11mo ago
Ratelimits are dynamically assigned by the API based on current load and may change at any point. - The scale from okay to API-spam is sliding and depends heavily on the action you are taking - Rainbow roles, clock and counter channels, and DM'ing advertisements to all members are all examples of things that are not okay
meow
meow11mo ago
hmm