diff options
| author | 2022-05-09 18:21:21 +0200 | |
|---|---|---|
| committer | 2022-05-09 18:21:21 +0200 | |
| commit | 019983c3785191a0c7182c62394cec2bac123d51 (patch) | |
| tree | 54c296bd04a13a0097cbd7249b78a6716556d735 /bot/exts/events/hacktoberfest/hacktober-issue-finder.py | |
| parent | Doublefixed indentation and removed unused import. (diff) | |
| parent | Bump pillow from 9.0.0 to 9.0.1 (#1045) (diff) | |
Merge branch 'main' into uwu
Diffstat (limited to 'bot/exts/events/hacktoberfest/hacktober-issue-finder.py')
| -rw-r--r-- | bot/exts/events/hacktoberfest/hacktober-issue-finder.py | 11 | 
1 files changed, 6 insertions, 5 deletions
diff --git a/bot/exts/events/hacktoberfest/hacktober-issue-finder.py b/bot/exts/events/hacktoberfest/hacktober-issue-finder.py index e3053851..1774564b 100644 --- a/bot/exts/events/hacktoberfest/hacktober-issue-finder.py +++ b/bot/exts/events/hacktoberfest/hacktober-issue-finder.py @@ -52,10 +52,10 @@ class HacktoberIssues(commands.Cog):      async def get_issues(self, ctx: commands.Context, option: str) -> Optional[dict]:          """Get a list of the python issues with the label 'hacktoberfest' from the Github api."""          if option == "beginner": -            if (ctx.message.created_at - self.cache_timer_beginner).seconds <= 60: +            if (ctx.message.created_at.replace(tzinfo=None) - self.cache_timer_beginner).seconds <= 60:                  log.debug("using cache")                  return self.cache_beginner -        elif (ctx.message.created_at - self.cache_timer_normal).seconds <= 60: +        elif (ctx.message.created_at.replace(tzinfo=None) - self.cache_timer_normal).seconds <= 60:              log.debug("using cache")              return self.cache_normal @@ -88,10 +88,10 @@ class HacktoberIssues(commands.Cog):              if option == "beginner":                  self.cache_beginner = data -                self.cache_timer_beginner = ctx.message.created_at +                self.cache_timer_beginner = ctx.message.created_at.replace(tzinfo=None)              else:                  self.cache_normal = data -                self.cache_timer_normal = ctx.message.created_at +                self.cache_timer_normal = ctx.message.created_at.replace(tzinfo=None)              return data @@ -100,7 +100,8 @@ class HacktoberIssues(commands.Cog):          """Format the issue data into a embed."""          title = issue["title"]          issue_url = issue["url"].replace("api.", "").replace("/repos/", "/") -        body = issue["body"] +        # issues can have empty bodies, which in that case GitHub doesn't include the key in the API response +        body = issue.get("body", "")          labels = [label["name"] for label in issue["labels"]]          embed = discord.Embed(title=title)  |