Skip to content

Commit fe960fb

Browse files
committed
Added version checker
Signed-off-by: ColaIan <colaian.yt@gmail.com>
1 parent 5f3b4a9 commit fe960fb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Teapot.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
import time
33
from os.path import join, dirname
4+
import json
5+
import requests
46

57
import discord
68
from discord.ext import commands as dcmd
@@ -19,6 +21,24 @@
1921
Running Teapot.py {teapot.version()}
2022
""")
2123

24+
req = requests.get(f'https://api.github.com/repos/RedCokeDevelopment/Teapot.py/tags')
25+
response = json.loads(req.text)
26+
if req.status_code == 200:
27+
if response[0]['name'] == teapot.version():
28+
print("You are currently running the latest version of Teapot.py!\n")
29+
else:
30+
versionlisted = False
31+
for x in response:
32+
if x['name'] == teapot.version():
33+
versionlisted = True
34+
print("You are not using our latest version! :(\n")
35+
if not versionlisted:
36+
print("You are currently using an unlisted version!\n")
37+
elif req.status_code == 404:
38+
print("Unable to fetch the latest Teapot.py version from GitHub!\n")
39+
else:
40+
print("An unknown error has occurred when fetching the latest version of Teapot.py\n")
41+
2242
load_dotenv(join(dirname(__file__), '.env'))
2343

2444
if os.getenv('CONFIG_VERSION') != teapot.config_version():

0 commit comments

Comments
 (0)