Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To install any cog you want:
[p]cog install maxcogs <cog name you want>
```
---------------------------------------------------------------
## Cogs on this repo:
## Cogs on this repo:
- Autopublisher
- Automatically publish messages in news channels
- Counting
Expand Down
6 changes: 3 additions & 3 deletions easterhunt/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"hidden": false,
"min_bot_version": "3.5.21",
"tags": [
"easter",
"hunting",
"easter eggs",
"easter",
"hunting",
"easter eggs",
"economy"
],
"permissions": [],
Expand Down
2 changes: 1 addition & 1 deletion heist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Check cooldowns for all heists.<br/>
- Usage: `[p]heist cooldowns`
- Slash Usage: `/heist cooldowns`
- Aliases: `cooldown`

# [p]heistset
Manage global heist settings.<br/>
- Usage: `[p]heistset`
Expand Down
120 changes: 61 additions & 59 deletions history/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,64 +115,66 @@ async def history(
- `[p]history` - Events for today.
- `[p]history 12 25` - Events for December 25.
"""
await ctx.typing()
user_tz: str = await self.config.user(ctx.author).timezone()
try:
tz = ZoneInfo(user_tz)
except ZoneInfoNotFoundError:
tz = ZoneInfo("UTC")
log.warning(
f"Invalid timezone '{user_tz}' for user {ctx.author.id}, falling back to UTC."
)

if (month is None) != (day is None):
return await ctx.send("Please provide both month and day, or neither.")

if month is None or day is None:
today = datetime.now(tz)
month = today.month
day = today.day
display_date: str = today.strftime("%B %d")
else:
async with ctx.typing():
user_tz: str = await self.config.user(ctx.author).timezone()
try:
display_date = datetime(2000, month, day).strftime("%B %d")
except ValueError:
return await ctx.send("Invalid date. Please provide a real month (1-12) and day.")

month_str: str = f"{month:02d}"
day_str: str = f"{day:02d}"

try:
events: list[dict[str, Any]] = await fetch_events(self.session, month_str, day_str)
except ValueError as e:
log.error(
f"Failed to fetch events for {month_str}/{day_str}: {str(e)}",
exc_info=True,
)
return await ctx.send(
f"Failed to fetch events for {display_date}. Please try again later."
)

if not events:
return await ctx.send(f"No notable events found for {display_date}.")
tz = ZoneInfo(user_tz)
except ZoneInfoNotFoundError:
tz = ZoneInfo("UTC")
log.warning(
f"Invalid timezone '{user_tz}' for user {ctx.author.id}, falling back to UTC."
)

if (month is None) != (day is None):
return await ctx.send("Please provide both month and day, or neither.")

if month is None or day is None:
today = datetime.now(tz)
month = today.month
day = today.day
display_date: str = today.strftime("%B %d")
else:
try:
display_date = datetime(2000, month, day).strftime("%B %d")
except ValueError:
return await ctx.send(
"Invalid date. Please provide a real month (1-12) and day."
)

month_str: str = f"{month:02d}"
day_str: str = f"{day:02d}"

pages: list[discord.Embed] = []
items_per_page: int = 10
for i in range(0, len(events), items_per_page):
chunk = events[i : i + items_per_page]
embed = discord.Embed(
title=f"On This Day: {display_date}", color=await ctx.embed_color()
)
for event in chunk:
year: str | int = event.get("year", "Unknown Year")
text: str = event.get("text", "No description available.")
display_year: str = format_year(year)
embed.add_field(name=display_year, value=text, inline=False)
current_page: int = i // items_per_page + 1
total_pages: int = (len(events) - 1) // items_per_page + 1
embed.set_footer(
text=f"Source: Wikipedia | Timezone: {user_tz} | Page {current_page}/{total_pages}",
icon_url=WIKIPEDIA_LOGO,
)
pages.append(embed)
await SimpleMenu(pages, disable_after_timeout=True, timeout=120).start(ctx)
try:
events: list[dict[str, Any]] = await fetch_events(self.session, month_str, day_str)
except ValueError as e:
log.error(
f"Failed to fetch events for {month_str}/{day_str}: {str(e)}",
exc_info=True,
)
return await ctx.send(
f"Failed to fetch events for {display_date}. Please try again later."
)

if not events:
return await ctx.send(f"No notable events found for {display_date}.")

pages: list[discord.Embed] = []
items_per_page: int = 10
for i in range(0, len(events), items_per_page):
chunk = events[i : i + items_per_page]
embed = discord.Embed(
title=f"On This Day: {display_date}", color=await ctx.embed_color()
)
for event in chunk:
year: str | int = event.get("year", "Unknown Year")
text: str = event.get("text", "No description available.")
display_year: str = format_year(year)
embed.add_field(name=display_year, value=text, inline=False)
current_page: int = i // items_per_page + 1
total_pages: int = (len(events) - 1) // items_per_page + 1
embed.set_footer(
text=f"Source: Wikipedia | Timezone: {user_tz} | Page {current_page}/{total_pages}",
icon_url=WIKIPEDIA_LOGO,
)
pages.append(embed)
await SimpleMenu(pages, disable_after_timeout=True, timeout=120).start(ctx)
46 changes: 24 additions & 22 deletions honeycombs/honeycombs.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,29 +434,31 @@ async def setimage(self, ctx: commands.Context, *, image_url: Optional[str] = No
You can set the image by providing a URL or by attaching an image/gif to the command.
Only JPG / JPEG / PNG / GIF / WEBP format is supported.
"""
await ctx.typing()
if len(ctx.message.attachments) > 0:
image_url = ctx.message.attachments[0].url
elif image_url is None:
return await ctx.send("You must provide a URL or attach an image.")

try:
async with self.session.get(image_url, timeout=aiohttp.ClientTimeout(total=10)) as r:
if r.status != 200:
return await ctx.send("Failed to set the start image. URL is invalid.")
data = await r.read()
except aiohttp.ClientError:
return await ctx.send("Failed to set the start image. Client error.")
except asyncio.TimeoutError:
return await ctx.send("Failed to set the start image. Timeout error.")

if not data or not any(data.startswith(sig) for sig in MAGIC_BYTES):
return await ctx.send(
f"Failed to set the start image. Only {humanize_list(list(MAGIC_BYTES.values()))} format is supported."
)
async with ctx.typing():
if len(ctx.message.attachments) > 0:
image_url = ctx.message.attachments[0].url
elif image_url is None:
return await ctx.send("You must provide a URL or attach an image.")

try:
async with self.session.get(
image_url, timeout=aiohttp.ClientTimeout(total=10)
) as r:
if r.status != 200:
return await ctx.send("Failed to set the start image. URL is invalid.")
data = await r.read()
except aiohttp.ClientError:
return await ctx.send("Failed to set the start image. Client error.")
except asyncio.TimeoutError:
return await ctx.send("Failed to set the start image. Timeout error.")

if not data or not any(data.startswith(sig) for sig in MAGIC_BYTES):
return await ctx.send(
f"Failed to set the start image. Only {humanize_list(list(MAGIC_BYTES.values()))} format is supported."
)

await self.update_guild_config(ctx.guild, "default_start_image", image_url)
await ctx.send("The start image has been set.")
await self.update_guild_config(ctx.guild, "default_start_image", image_url)
await ctx.send("The start image has been set.")

@setimage.command(name="clear", aliases=["reset"])
@commands.admin()
Expand Down
88 changes: 87 additions & 1 deletion nba/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NBA

NBA information cog.<br/>- Get the current NBA schedule for the next game.<br/>- Get the current NBA scoreboard.<br/>- Get the latest NBA news.<br/>- Set the channel to send NBA game updates to.
NBA information cog.<br/>- Get the current NBA schedule for the next game.<br/>- Get the current NBA scoreboard.<br/>- Get the latest NBA news.<br/>- Get standings, stat leaders, player info, rosters, and team stats.<br/>- Set the channel to send NBA game updates to.

## [p]nbaset

Expand Down Expand Up @@ -54,6 +54,18 @@ You can only set one channel and one team per server.<br/>

- Usage: `[p]nbaset channel <channel> <team>`

### [p]nbaset role set

Set a role to ping 30 minutes before game starts.<br/>

- Usage: `[p]nbaset role set <role>`

### [p]nbaset role remove

Remove the pre-game ping role.<br/>

- Usage: `[p]nbaset role remove`

## [p]nba (Hybrid Command)

Get the current NBA schedule for next game.<br/>
Expand Down Expand Up @@ -112,3 +124,77 @@ Get the current NBA scoreboard.<br/>
- Slash Usage: `/nba scoreboard [team=None]`
- Aliases: `score and scores`
- Cooldown: `1 per 3.0 seconds`

### [p]nba standings (Hybrid Command)

Get the current NBA standings.<br/>

Shows win/loss record, win%, games behind, home/road record, last 10, streak, and clinch indicator for every team.<br/>

**Arguments:**<br/>
- `[conference]` - Filter to `east` or `west`. Shows both if omitted.<br/>

- Usage: `[p]nba standings [conference]`
- Slash Usage: `/nba standings [conference]`
- Cooldown: `1 per 10.0 seconds`

### [p]nba leaders (Hybrid Command)

Get the NBA per-game stat leaders.<br/>

**Arguments:**<br/>
- `[category]` - One of `pts`, `reb`, `ast`, `stl`, `blk`. Defaults to `pts`.<br/>

**Examples:**<br/>
- `[p]nba leaders` - Returns the top points-per-game leaders.<br/>
- `[p]nba leaders reb` - Returns the top rebounders.<br/>
- `[p]nba leaders ast` - Returns the top assist leaders.<br/>

- Usage: `[p]nba leaders [category=pts]`
- Slash Usage: `/nba leaders [category=pts]`
- Cooldown: `1 per 10.0 seconds`

### [p]nba player (Hybrid Command)

Get bio and career stats for an NBA player.<br/>

**Arguments:**<br/>
- `<name>` - The player's name to look up (e.g. `LeBron James`).<br/>

**Examples:**<br/>
- `[p]nba player LeBron James`<br/>
- `[p]nba player curry`<br/>

- Usage: `[p]nba player <name>`
- Slash Usage: `/nba player <name>`
- Cooldown: `1 per 10.0 seconds`

### [p]nba roster (Hybrid Command)

Get the current roster for an NBA team.<br/>

**Arguments:**<br/>
- `<team>` - The team name (e.g. `lakers`, `celtics`).<br/>

**Valid Team Names:**<br/>
- heat, bucks, bulls, cavaliers, celtics, clippers, grizzlies, hawks, hornets, jazz, kings, knicks, lakers, magic, mavericks, nets, nuggets, pacers, pelicans, pistons, raptors, rockets, sixers, spurs, suns, thunder, timberwolves, trail blazers, warriors, wizards<br/>

- Usage: `[p]nba roster <team>`
- Slash Usage: `/nba roster <team>`
- Cooldown: `1 per 10.0 seconds`

### [p]nba teamstats (Hybrid Command)

Get season averages for an NBA team.<br/>

Shows per-game averages for points, rebounds, assists, steals, blocks, turnovers, shooting splits, and plus/minus.<br/>

**Arguments:**<br/>
- `<team>` - The team name (e.g. `warriors`, `heat`).<br/>

**Valid Team Names:**<br/>
- heat, bucks, bulls, cavaliers, celtics, clippers, grizzlies, hawks, hornets, jazz, kings, knicks, lakers, magic, mavericks, nets, nuggets, pacers, pelicans, pistons, raptors, rockets, sixers, spurs, suns, thunder, timberwolves, trail blazers, warriors, wizards<br/>

- Usage: `[p]nba teamstats <team>`
- Slash Usage: `/nba teamstats <team>`
- Cooldown: `1 per 10.0 seconds`
Loading
Loading