diff options
| author | 2021-10-14 22:34:41 +0100 | |
|---|---|---|
| committer | 2021-10-14 22:34:41 +0100 | |
| commit | 4fd0acedd4b6f994ecb3299b93ea48115f61d785 (patch) | |
| tree | 1bed49893eada22908fb93632bbfe88eaa6f00ed /bot/exts/events/hacktoberfest/hacktober-issue-finder.py | |
| parent | Change pascal's triangle image (diff) | |
| parent | Add support to query AoC results in respect of days and stars (#857) (diff) | |
Merge branch 'main' into fix-pascal-triangle-image
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) |