Skip to content

Commit 361a3b4

Browse files
authored
Merge pull request #25 from Nazar1ky/github-api
2 parents 38f86e7 + a736a09 commit 361a3b4

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

cogs/utils/github.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import requests
2-
from bs4 import BeautifulSoup
32

43
def get_latest():
54
response = requests.get("https://raw.githubusercontent.com/r-liner/discord-commands-bot/master/version.txt")
@@ -13,9 +12,21 @@ def check_for_updates(version):
1312
return False
1413

1514
def changelog():
16-
latest = get_latest()
17-
response = requests.get(f"https://github.com/r-liner/discord-commands-bot/releases/tag/v{latest}")
18-
soup = BeautifulSoup(response.text, "html.parser")
19-
_changelog = soup.find("div", class_="markdown-body my-3").get_text()
15+
headers = {
16+
"Accept": "application/vnd.github.v3.text+json",
17+
}
18+
19+
response = requests.get(
20+
"https://api.github.com/repos/liner-exe/discord-commands-bot/releases/latest",
21+
headers=headers,
22+
)
23+
24+
if not response.ok:
25+
return ""
26+
27+
data = response.json()
28+
29+
if not data.get("body_text"):
30+
return "" # Raise there error if needed
2031

21-
return _changelog
32+
return data["body_text"]

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ nextcord==2.6.0
33
typing_extensions==4.9.0
44
psutil==5.9.8
55
requests==2.31.0
6-
beautifulsoup4==4.12.3

0 commit comments

Comments
 (0)