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

fix: 서버 수 업데이트 시 오류 핸들링 #46

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions koreanbots/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ async def request(
async with self.session.request(
method, KOREANBOTS_URL + endpoint, **kwargs
) as response:
remain_limit = response.headers["x-ratelimit-remaining"]
if int(remain_limit) == 0 or response.status == 429:
remain_limit = response.headers.get("x-ratelimit-remaining")
if (
remain_limit is not None
and int(remain_limit) == 0
or response.status == 429
):
reset_limit_timestamp = int(response.headers["x-ratelimit-reset"])
eunwoo1104 marked this conversation as resolved.
Show resolved Hide resolved
reset_limit = datetime.fromtimestamp(reset_limit_timestamp)
retry_after = reset_limit - datetime.now()
Expand Down
12 changes: 9 additions & 3 deletions koreanbots/integrations/dico.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ async def tasks_send_guildcount(self) -> None:
if self.include_shard_count:
if self.client.shard_count:
kwargs.update({"shards": self.client.shard_count})
log.info("Send")
await self.guildcount(int(self.client.application_id), **kwargs)
log.info("Complete i will sleep")
log.info("Initiating guild count update...")
try:
await self.guildcount(int(self.client.application_id), **kwargs)
except:
log.exception("Guild count update failed due to an error.")
else:
log.info(
"Guild count updated successfully. Waiting 30 minutes for the next update."
)
await sleep(1800)
12 changes: 9 additions & 3 deletions koreanbots/integrations/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ async def tasks_send_guildcount(self) -> None:
if self.include_shard_count:
if self.client.shard_count:
kwargs.update({"shards": self.client.shard_count})
log.info("Send")
await self.guildcount(self.client.user.id, **kwargs)
log.info("Complete i will sleep")
log.info("Initiating guild count update...")
try:
await self.guildcount(int(self.client.user.id), **kwargs)
except:
log.exception("Guild count update failed due to an error.")
else:
log.info(
"Guild count updated successfully. Waiting 30 minutes for the next update."
)
await sleep(1800)
Loading