Skip to content

Commit f88e484

Browse files
authored
Merge pull request #15 from Insermius-Dev/website-update
Website rewrite
2 parents 30ac9d9 + 4ab08e8 commit f88e484

File tree

15 files changed

+636
-408
lines changed

15 files changed

+636
-408
lines changed

Bot_website.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,30 @@
33

44
app = Flask("")
55

6+
67
@app.route("/")
78
def index():
8-
return render_template("index.html", contributors=contributors, lilhelpers=lilhelpers, developer=developer)
9+
return render_template("index.html", contributors=contributors, helpers=helpers, developer=developer)
10+
# return render_template("index.html")
911

1012

1113
def run():
1214
app.run(host="0.0.0.0", port=8080)
1315

1416

15-
def start(contr, lilhelp, dev):
17+
def start(contr, hlpr, dev) -> None:
18+
# def start():
1619
global contributors
17-
global lilhelpers
20+
global helpers
1821
global developer
22+
1923
contributors = contr
20-
lilhelpers = lilhelp
24+
helpers = hlpr
2125
developer = dev
26+
2227
t = Thread(target=run)
23-
t.start()
28+
t.start()
29+
30+
31+
if __name__ == "__main__":
32+
start()

README.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

const.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
"Anime"
3939
]
4040

41-
EPIC_CONTRIBUTING_PPL = []
41+
CONTRIBUTORS = []
4242

43-
LIL_HELPERS = []
43+
HELPERS = []
4444

4545
DELETE_BTN = Button(style=ButtonStyle.RED, custom_id="delete", emoji="🗑️")
4646

data/compo_callback.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from interactions import *
22
from datetime import *
3-
from const import DELETE_BTN, EPIC_CONTRIBUTING_PPL, LIL_HELPERS, NAMEDAYS_EXT
3+
from const import DELETE_BTN, CONTRIBUTORS, HELPERS, NAMEDAYS_EXT
44

55

66
class callback(Extension) :
@@ -22,7 +22,7 @@ async def on_component(self, ctx: ComponentContext):
2222
footer=EmbedFooter(text=f"Requested by {event.author.display_name}", icon_url=event.author.avatar.url)
2323
)
2424
value = ""
25-
for contributor in EPIC_CONTRIBUTING_PPL:
25+
for contributor in CONTRIBUTORS:
2626
value += f"> <@{contributor}> \n"
2727

2828
embed.add_field(
@@ -31,7 +31,7 @@ async def on_component(self, ctx: ComponentContext):
3131
)
3232

3333
value = ""
34-
for lilhelper in LIL_HELPERS:
34+
for lilhelper in HELPERS:
3535
value += f"> <@{lilhelper}> \n"
3636

3737
embed.add_field(

data/lichess.py

Lines changed: 79 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -18,88 +18,90 @@
1818

1919
delete_btn = Button(style=ButtonStyle.RED, custom_id="delete", emoji="🗑️")
2020

21-
load_dotenv()
22-
api_key = os.getenv("LICHESS_API")
21+
try:
22+
load_dotenv()
23+
api_key = os.getenv("LICHESS_API")
2324

24-
session = lichess.TokenSession(api_key)
25-
client = lichess.Client(session=session)
25+
session = lichess.TokenSession(api_key)
26+
client = lichess.Client(session=session)
27+
except:
28+
print("Lichess API key not found")
29+
client = None
2630

2731

2832
class Lichess(Extension):
29-
@slash_command(name="lichess", description="Get lichess stats")
30-
@slash_option(
31-
name="username",
32-
description="Input a username to get stats",
33-
required=True,
34-
opt_type=OptionType.STRING,
35-
)
36-
async def lichess(self, ctx, username):
37-
38-
# TODO: Get the user statuses to work
39-
40-
try:
41-
user = client.users.get_public_data(username)
42-
# userstatus = client.users.get_realtime_statuses(user)[0].get("online")
43-
except Exception as e:
44-
await ctx.send(f"```{e}```")
45-
return
46-
if user["perfs"]["bullet"]["games"] < 10:
47-
user["perfs"]["bullet"]["rating"] = str(user["perfs"]["bullet"]["rating"]) + "?"
48-
if user["perfs"]["blitz"]["games"] < 10:
49-
user["perfs"]["blitz"]["rating"] = str(user["perfs"]["blitz"]["rating"]) + "?"
50-
if user["perfs"]["rapid"]["games"] < 10:
51-
user["perfs"]["rapid"]["rating"] = str(user["perfs"]["rapid"]["rating"]) + "?"
52-
if user["perfs"]["classical"]["games"] < 10:
53-
user["perfs"]["classical"]["rating"] = str(user["perfs"]["classical"]["rating"]) + "?"
54-
if user["perfs"].get("puzzle") == None:
55-
user["perfs"]["puzzle"] = {"games": 0, "rating": 1500}
56-
if user["perfs"]["puzzle"]["games"] < 10:
57-
user["perfs"]["puzzle"]["rating"] = str(user["perfs"]["puzzle"]["rating"]) + "?"
58-
# if userstatus:
59-
# if user["patron"]:
60-
# status = f"<:Don_online:1059387820097142794> [{user['username']}]({user['url']})"
61-
# else:
62-
# status = f"<:Nor_online:1059387814854271006> [{user['username']}]({user['url']})"
63-
# elif userstatus == None:
64-
# if user["patron"]:
65-
# status = f"<:Don_offline:1059387818566238269> [{user['username']}]({user['url']})"
66-
# else:
67-
# status = f"<:Nor_offline:1059387816833982514> [{user['username']}]({user['url']})"
68-
if user.get("patron"):
69-
user["patron"] = "<:Donator:1059387813235273728> Activated"
70-
else:
71-
user["patron"] = "<:Normal:1059387811687567380> Not activated"
72-
embed = Embed(
73-
title=f"{user['username']}'s Lichess Stats",
74-
thumbnail="https://cdn.discordapp.com/attachments/1054486043665125436/1059235301056331816/Lichess_Logo_2019.png",
75-
color=Color.from_hex("#FFFFFF"),
76-
timestamp=datetime.now(),
77-
)
78-
embed.set_footer(
79-
text=f"Requested by {ctx.author.display_name}", icon_url=ctx.author.avatar.url
80-
)
81-
embed.add_field(
82-
name="Ratings",
83-
value=f"""
84-
> **Bullet:** {user['perfs']['bullet']['rating']}
85-
> **Blitz:** {user['perfs']['blitz']['rating']}
86-
> **Rapid:** {user['perfs']['rapid']['rating']}
87-
> **Classical:** {user['perfs']['classical']['rating']}
88-
> **Puzzle:** {user['perfs']['puzzle']['rating']}
89-
""",
90-
)
91-
embed.add_field(
92-
name="Stats",
93-
value=f"""
94-
> **Games:** {user['count']['all']}
95-
> **Wins:** {user['count']['win']}
96-
> **Losses:** {user['count']['loss']}
97-
> **Draws:** {user['count']['draw']}
98-
""",
33+
if client != None:
34+
@slash_command(name="lichess", description="Get lichess stats")
35+
@slash_option(
36+
name="username",
37+
description="Input a username to get stats",
38+
required=True,
39+
opt_type=OptionType.STRING,
9940
)
100-
embed.add_field(name="Patron status", value=f"> {user['patron']}")
101-
# embed.add_field(name="Full profile", value=f"> {status}")
102-
await ctx.send(embed=embed, components=[delete_btn])
41+
async def lichess(self, ctx, username):
42+
try:
43+
user = client.users.get_public_data(username)
44+
# userstatus = client.users.get_realtime_statuses(user)[0].get("online")
45+
except Exception as e:
46+
await ctx.send(f"```{e}```")
47+
return
48+
if user["perfs"]["bullet"]["games"] < 10:
49+
user["perfs"]["bullet"]["rating"] = str(user["perfs"]["bullet"]["rating"]) + "?"
50+
if user["perfs"]["blitz"]["games"] < 10:
51+
user["perfs"]["blitz"]["rating"] = str(user["perfs"]["blitz"]["rating"]) + "?"
52+
if user["perfs"]["rapid"]["games"] < 10:
53+
user["perfs"]["rapid"]["rating"] = str(user["perfs"]["rapid"]["rating"]) + "?"
54+
if user["perfs"]["classical"]["games"] < 10:
55+
user["perfs"]["classical"]["rating"] = str(user["perfs"]["classical"]["rating"]) + "?"
56+
if user["perfs"].get("puzzle") == None:
57+
user["perfs"]["puzzle"] = {"games": 0, "rating": 1500}
58+
if user["perfs"]["puzzle"]["games"] < 10:
59+
user["perfs"]["puzzle"]["rating"] = str(user["perfs"]["puzzle"]["rating"]) + "?"
60+
# if userstatus:
61+
# if user["patron"]:
62+
# status = f"<:Don_online:1059387820097142794> [{user['username']}]({user['url']})"
63+
# else:
64+
# status = f"<:Nor_online:1059387814854271006> [{user['username']}]({user['url']})"
65+
# elif userstatus == None:
66+
# if user["patron"]:
67+
# status = f"<:Don_offline:1059387818566238269> [{user['username']}]({user['url']})"
68+
# else:
69+
# status = f"<:Nor_offline:1059387816833982514> [{user['username']}]({user['url']})"
70+
if user.get("patron"):
71+
user["patron"] = "<:Donator:1059387813235273728> Activated"
72+
else:
73+
user["patron"] = "<:Normal:1059387811687567380> Not activated"
74+
embed = Embed(
75+
title=f"{user['username']}'s Lichess Stats",
76+
thumbnail="https://cdn.discordapp.com/attachments/1054486043665125436/1059235301056331816/Lichess_Logo_2019.png",
77+
color=Color.from_hex("#FFFFFF"),
78+
timestamp=datetime.now(),
79+
)
80+
embed.set_footer(
81+
text=f"Requested by {ctx.author.display_name}", icon_url=ctx.author.avatar.url
82+
)
83+
embed.add_field(
84+
name="Ratings",
85+
value=f"""
86+
> **Bullet:** {user['perfs']['bullet']['rating']}
87+
> **Blitz:** {user['perfs']['blitz']['rating']}
88+
> **Rapid:** {user['perfs']['rapid']['rating']}
89+
> **Classical:** {user['perfs']['classical']['rating']}
90+
> **Puzzle:** {user['perfs']['puzzle']['rating']}
91+
""",
92+
)
93+
embed.add_field(
94+
name="Stats",
95+
value=f"""
96+
> **Games:** {user['count']['all']}
97+
> **Wins:** {user['count']['win']}
98+
> **Losses:** {user['count']['loss']}
99+
> **Draws:** {user['count']['draw']}
100+
""",
101+
)
102+
embed.add_field(name="Patron status", value=f"> {user['patron']}")
103+
# embed.add_field(name="Full profile", value=f"> {status}")
104+
await ctx.send(embed=embed, components=[delete_btn])
103105

104106

105107
def setup(bot):

0 commit comments

Comments
 (0)