aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/exts/evergreen/issues.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/bot/exts/evergreen/issues.py b/bot/exts/evergreen/issues.py
index e128ae50..15c97473 100644
--- a/bot/exts/evergreen/issues.py
+++ b/bot/exts/evergreen/issues.py
@@ -4,7 +4,7 @@ import random
import discord
from discord.ext import commands
-from bot.constants import Channels, Colours, Emojis, ERROR_REPLIES, WHITELISTED_CHANNELS
+from bot.constants import Channels, Colours, Emojis, ERROR_REPLIES, Tokens, WHITELISTED_CHANNELS
from bot.utils.decorators import override_in_channel
log = logging.getLogger(__name__)
@@ -16,6 +16,10 @@ BAD_RESPONSE = {
MAX_REQUESTS = 10
+REQUEST_HEADERS = dict()
+if GITHUB_TOKEN := Tokens.github:
+ REQUEST_HEADERS["Authorization"] = f"token {GITHUB_TOKEN}"
+
class Issues(commands.Cog):
"""Cog that allows users to retrieve issues from GitHub."""
@@ -30,7 +34,7 @@ class Issues(commands.Cog):
ctx: commands.Context,
numbers: commands.Greedy[int],
repository: str = "seasonalbot",
- user: str = "python-discord"
+ user: str = "python-discord"
) -> None:
"""Command to retrieve issue(s) from a GitHub repository."""
links = []
@@ -55,7 +59,7 @@ class Issues(commands.Cog):
merge_url = f"https://api.github.com/repos/{user}/{repository}/pulls/{number}/merge"
log.trace(f"Querying GH issues API: {url}")
- async with self.bot.http_session.get(url) as r:
+ async with self.bot.http_session.get(url, headers=REQUEST_HEADERS) as r:
json_data = await r.json()
if r.status in BAD_RESPONSE: