diff options
author | 2021-04-08 12:37:14 -0400 | |
---|---|---|
committer | 2021-04-08 12:37:14 -0400 | |
commit | c94a45a10bac63eff1ce066707fe2df0b1243daa (patch) | |
tree | c8cdc00edabaa9db3df06e58f70f9e699a253f16 /bot/exts/evergreen/issues.py | |
parent | Merge pull request #637 from python-discord/dependabot/pip/pyyaml-5.4 (diff) |
Use PRDraft emoji when the pr is a draft pr for the .issue|.pr command
Diffstat (limited to 'bot/exts/evergreen/issues.py')
-rw-r--r-- | bot/exts/evergreen/issues.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/bot/exts/evergreen/issues.py b/bot/exts/evergreen/issues.py index 4a73d20b..e83f1a3e 100644 --- a/bot/exts/evergreen/issues.py +++ b/bot/exts/evergreen/issues.py @@ -100,7 +100,7 @@ class Issues(commands.Cog): for number in numbers: url = f"https://api.github.com/repos/{user}/{repository}/issues/{number}" - merge_url = f"https://api.github.com/repos/{user}/{repository}/pulls/{number}/merge" + pulls_url = f"https://api.github.com/repos/{user}/{repository}/pulls/{number}" log.trace(f"Querying GH issues API: {url}") async with self.bot.http_session.get(url, headers=REQUEST_HEADERS) as r: json_data = await r.json() @@ -123,12 +123,15 @@ class Issues(commands.Cog): # we know that a PR has been requested and a call to the pulls API endpoint is necessary # to get the desired information for the PR. else: - log.trace(f"PR provided, querying GH pulls API for additional information: {merge_url}") - async with self.bot.http_session.get(merge_url) as m: - if json_data.get("state") == "open": + log.trace(f"PR provided, querying GH pulls API for additional information: {pulls_url}") + async with self.bot.http_session.get(pulls_url) as p: + pull_data = await p.json() + if pull_data["draft"]: + icon_url = Emojis.pull_request_draft + elif pull_data["state"] == "open": icon_url = Emojis.pull_request # When the status is 204 this means that the state of the PR is merged - elif m.status == 204: + elif pull_data["merged_at"] is not None: icon_url = Emojis.merge else: icon_url = Emojis.pull_request_closed |