drop months in the past
All checks were successful
Build and push / changes (push) Successful in 3s
Build and push / Lint-Python (push) Successful in 2s
Build and push / Build-and-Push-Docker (push) Successful in 2m30s
Build and push / post-status-to-discord (push) Successful in 1s
Build and push / sync-argocd-app (push) Successful in 2s
All checks were successful
Build and push / changes (push) Successful in 3s
Build and push / Lint-Python (push) Successful in 2s
Build and push / Build-and-Push-Docker (push) Successful in 2m30s
Build and push / post-status-to-discord (push) Successful in 1s
Build and push / sync-argocd-app (push) Successful in 2s
This commit is contained in:
parent
7d262becd5
commit
cf3000e2c9
@ -2,6 +2,7 @@ from discord.ext import commands
|
|||||||
import discord
|
import discord
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
class TrackDays(commands.Cog):
|
class TrackDays(commands.Cog):
|
||||||
@ -68,8 +69,33 @@ class TrackDays(commands.Cog):
|
|||||||
|
|
||||||
months = soup.find_all("h4", class_="month")
|
months = soup.find_all("h4", class_="month")
|
||||||
|
|
||||||
|
# Create a month order mapping
|
||||||
|
month_order = {
|
||||||
|
"January": 1,
|
||||||
|
"February": 2,
|
||||||
|
"March": 3,
|
||||||
|
"April": 4,
|
||||||
|
"May": 5,
|
||||||
|
"June": 6,
|
||||||
|
"July": 7,
|
||||||
|
"August": 8,
|
||||||
|
"September": 9,
|
||||||
|
"October": 10,
|
||||||
|
"November": 11,
|
||||||
|
"December": 12,
|
||||||
|
}
|
||||||
|
|
||||||
|
current_month = datetime.datetime.now().month
|
||||||
|
current_year = datetime.datetime.now().year
|
||||||
|
|
||||||
for month in months:
|
for month in months:
|
||||||
month_name = month.text
|
month_name = month.text
|
||||||
|
month_num = month_order[month_name]
|
||||||
|
|
||||||
|
# Skip if month is in the past
|
||||||
|
if month_num < current_month:
|
||||||
|
continue
|
||||||
|
|
||||||
data[month_name] = {"events": []}
|
data[month_name] = {"events": []}
|
||||||
|
|
||||||
events = month.find_next(
|
events = month.find_next(
|
||||||
@ -89,22 +115,6 @@ class TrackDays(commands.Cog):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create a month order mapping
|
|
||||||
month_order = {
|
|
||||||
"January": 1,
|
|
||||||
"February": 2,
|
|
||||||
"March": 3,
|
|
||||||
"April": 4,
|
|
||||||
"May": 5,
|
|
||||||
"June": 6,
|
|
||||||
"July": 7,
|
|
||||||
"August": 8,
|
|
||||||
"September": 9,
|
|
||||||
"October": 10,
|
|
||||||
"November": 11,
|
|
||||||
"December": 12,
|
|
||||||
}
|
|
||||||
|
|
||||||
embed = discord.Embed(description="", color=discord.Color.blue(), type="rich")
|
embed = discord.Embed(description="", color=discord.Color.blue(), type="rich")
|
||||||
|
|
||||||
embed.set_author(name=track)
|
embed.set_author(name=track)
|
||||||
@ -113,14 +123,15 @@ class TrackDays(commands.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for month in sorted(data.keys(), key=lambda x: month_order[x]):
|
for month in sorted(data.keys(), key=lambda x: month_order[x]):
|
||||||
embed.add_field(
|
if data[month]["events"]: # Only add field if there are events
|
||||||
name=f"🏁 {month} 🏁\n---------",
|
embed.add_field(
|
||||||
value="\n".join(
|
name=f"🏁 {month} 🏁\n---------",
|
||||||
f"[{event['provider']}: {event['day']}]({event['reg_url']})"
|
value="\n".join(
|
||||||
for event in data[month]["events"]
|
f"[{event['provider']}: {event['day']}]({event['reg_url']})"
|
||||||
),
|
for event in data[month]["events"]
|
||||||
inline=False,
|
),
|
||||||
)
|
inline=False,
|
||||||
|
)
|
||||||
|
|
||||||
embed.set_footer(text="Pulled from https://www.trackpinata.com")
|
embed.set_footer(text="Pulled from https://www.trackpinata.com")
|
||||||
await ctx.send_followup(embed=embed)
|
await ctx.send_followup(embed=embed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user