Skip to content
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

Add rate limit checker to Discord integration #1722

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

garrrikkotua
Copy link
Contributor

@garrrikkotua garrrikkotua commented Oct 18, 2023

Changes proposed ✍️

What

🤖 Generated by Copilot at afdb1ef

This pull request adds rate limiting and error handling to the Discord API integration. It uses the handleRateLimit module to create and use a rate limiter for each API function. This improves the performance and the reliability of the integration and prevents errors from exceeding the API's request limit. It affects the files getChannel.ts, getChannels.ts, getMember.ts, getMembers.ts, getMessage.ts, getMessages.ts, getThreads.ts, and handleRateLimit.ts in the integrations/discord/api module.

🤖 Generated by Copilot at afdb1ef

We face the wrath of the Discord API
We must obey the rate limit or die
We use the handleRateLimit module
To tame the beast and make it stable

Why

How

🤖 Generated by Copilot at afdb1ef

  • Add the handleRateLimit module to create and use a rate limiter for the Discord API requests (link)
  • Import and initialize the rate limiter in the getChannel, getChannels, getMember, getMembers, getMessage, getMessages, and getThreads functions (link, link, link, link, link, link, link, link, link, link, link, link)
  • Check and increment the rate limit before and after making the requests to the Discord API in the getChannel, getMember, getMessages, and getThreads functions (link, link, link, link, link)
  • Import and use the handleDiscordError function to handle and log the possible errors from the Discord API in the getChannels and getThreads functions (link, link, link, link)
  • Simplify the code by removing the try blocks and moving the config variable declarations outside of them in the getChannels and getThreads functions (link, link)

Checklist ✅

  • Label appropriately with Feature, Improvement, or Bug.
  • Add screenshots to the PR description for relevant FE changes
  • New backend functionality has been unit-tested.
  • API documentation has been updated (if necessary) (see docs on API documentation).
  • Quality standards are met.

@garrrikkotua garrrikkotua merged commit 3dca0f3 into main Oct 18, 2023
8 checks passed
@garrrikkotua garrrikkotua deleted the improve/discord-rate-limits branch October 18, 2023 13:33
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.

None yet

1 participant