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 requests
|
||||
from bs4 import BeautifulSoup
|
||||
import datetime
|
||||
|
||||
|
||||
class TrackDays(commands.Cog):
|
||||
@ -68,8 +69,33 @@ class TrackDays(commands.Cog):
|
||||
|
||||
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:
|
||||
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": []}
|
||||
|
||||
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.set_author(name=track)
|
||||
@ -113,6 +123,7 @@ class TrackDays(commands.Cog):
|
||||
)
|
||||
|
||||
for month in sorted(data.keys(), key=lambda x: month_order[x]):
|
||||
if data[month]["events"]: # Only add field if there are events
|
||||
embed.add_field(
|
||||
name=f"🏁 {month} 🏁\n---------",
|
||||
value="\n".join(
|
||||
|
Loading…
x
Reference in New Issue
Block a user