Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e459d8a
feat(event): Initial event cog commit
simtiaz5 Jan 30, 2026
2a9d3cd
Merge branch 'main' of https://github.com/CApy-RPI/discord-bot into f…
simtiaz5 Feb 3, 2026
a906b04
feature(event): create __init__.py and _schemas.py files for event cog
simtiaz5 Feb 3, 2026
a559294
feature(event): created event class
simtiaz5 Feb 3, 2026
543239a
implement event schemas
simtiaz5 Feb 3, 2026
d1aa416
feature(event): add additonal actions and action handling.
simtiaz5 Feb 3, 2026
03f6eef
feature(event): created placeholder action handling functions
simtiaz5 Feb 3, 2026
e1c4e9d
refactor(event): renamed action functions
simtiaz5 Feb 3, 2026
4879b57
Merge branch 'develop' of https://github.com/CApy-RPI/discord-bot int…
simtiaz5 Feb 3, 2026
b5a9db5
feature(event): implemented logic for handling event creation
simtiaz5 Feb 3, 2026
2c43a58
fix(event): Seperated event and date inputs. Implemented timestamps. …
simtiaz5 Feb 3, 2026
74671bd
Merge branch 'develop' of https://github.com/CApy-RPI/discord-bot int…
simtiaz5 Feb 6, 2026
85e7528
feature(event): add pattern check to event schemas
simtiaz5 Feb 6, 2026
09e2d38
feature(event): Implemented edit event logic
simtiaz5 Feb 6, 2026
b7bf291
feature(event): Implemented show event action
simtiaz5 Feb 6, 2026
a53b431
feature(event): Implemented delete event logic
simtiaz5 Feb 6, 2026
6a07b8f
Merge branch 'develop' of https://github.com/CApy-RPI/discord-bot int…
simtiaz5 Feb 6, 2026
0bbf85b
feature(event): handle event listing
simtiaz5 Feb 6, 2026
0488eb0
event(feature): Implemetned event announcing.
simtiaz5 Feb 6, 2026
d2d2b6e
feature(event): implemented myevents handling
simtiaz5 Feb 6, 2026
9860422
refactor(event): Import annoucement channel name from config file. Co…
simtiaz5 Feb 9, 2026
2e130fe
Refactor(event): Moved redundant code into helper methods. Simplified…
simtiaz5 Feb 10, 2026
f4b2120
Merge branch 'develop' into feature/capr-23-scaffold-event_cog-from-d…
shamikkarkhanis Feb 10, 2026
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
3 changes: 3 additions & 0 deletions capy_discord/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ class Settings(EnvConfig):
# Ticket System Configuration
ticket_feedback_channel_id: int = 0

# Event System Configuration
announcement_channel_name: str = "test-announcements"

Comment on lines +28 to +30

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new setting is introduced but example.env doesn’t document it. Consider adding ANNOUNCEMENT_CHANNEL_NAME= (or whatever env var name is expected by pydantic-settings) to example.env/README so deployments know how to configure the announcement channel.

Copilot uses AI. Check for mistakes.

settings = Settings()
1 change: 1 addition & 0 deletions capy_discord/exts/event/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Event management module."""
43 changes: 43 additions & 0 deletions capy_discord/exts/event/_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from datetime import date, datetime, time

from pydantic import BaseModel, Field, field_validator


class EventSchema(BaseModel):
"""Pydantic model defining the Event schema and validation rules."""

event_name: str = Field(title="Event Name", description="Name of the event", max_length=100)
event_date: date = Field(
title="Event Date",
description="Date of the event (MM-DD-YYYY)",
default_factory=date.today,
)
Comment on lines +10 to +14

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event_date/event_time use default_factory, so ModelModal will mark these inputs as not required. If the user leaves an optional TextInput blank, Discord submits an empty string, and the current validators will try strptime on "", causing a validation error instead of falling back to the default. Consider making these fields required (remove defaults) and/or treating blank strings as missing in the validators so defaults apply.

Copilot uses AI. Check for mistakes.
event_time: time = Field(
title="Event Time",
description="Time of the event (HH:MM, 24-hour) or (HH:MM AM/PM)",
default_factory=lambda: datetime.now().astimezone().time(),
)
Comment on lines +10 to +19

Copilot AI Feb 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event_date/event_time use default_factory, which makes them non-required in Pydantic, so ModelModal will render them as optional with no default text. If the user leaves them blank, Discord submits an empty string and the validators will raise a parsing error instead of using the default. Either (1) make these fields required (remove defaults) or (2) treat blank strings as “missing” in the validators and substitute the intended default, and/or pass initial_data in the create modal to prefill current date/time.

Copilot uses AI. Check for mistakes.
location: str = Field(title="Location", description="Location of the event", max_length=200, default="")
description: str = Field(
title="Description", description="Detailed description of the event", max_length=1000, default=""
)

@field_validator("event_date", mode="before")
@classmethod
def _parse_event_date(cls, value: object) -> date | object:
if isinstance(value, str):
value = value.strip()
return datetime.strptime(f"{value} +0000", "%m-%d-%Y %z").date()
return value
Comment on lines +10 to +31

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event_date/event_time have default_factory, so ModelModal will mark them as not required. However, if the user leaves the inputs blank, Discord sends an empty string and the validators will attempt to strptime(''), causing validation errors instead of using defaults. Consider either making these fields required (no defaults) or updating the validators to treat empty/whitespace-only strings as “missing” and return the default value.

Copilot uses AI. Check for mistakes.

@field_validator("event_time", mode="before")
@classmethod
def _parse_event_time(cls, value: object) -> time | object:
if isinstance(value, str):
value = value.strip()
if " " in value:
parsed = datetime.strptime(f"{value} +0000", "%I:%M %p %z")
else:
parsed = datetime.strptime(f"{value} +0000", "%H:%M %z")
return parsed.timetz().replace(tzinfo=None)
Comment on lines +25 to +42

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New date/time parsing and validation logic in EventSchema is user-facing (it drives the modal input format) but currently has no unit tests. Adding tests for accepted formats (e.g., MM-DD-YYYY, HH:MM, HH:MM AM/PM) and failure/blank-input behavior would help prevent regressions, similar to how other cogs are covered under tests/capy_discord/exts/.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +42

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EventSchema.event_date / event_time have defaults, and ModelModal marks them as not-required, but the modal will still pass empty strings ("") when users leave the inputs blank. The validators currently attempt to parse "" and will raise a validation error instead of falling back to the default. Treat empty/whitespace-only strings as missing (e.g., return PydanticUndefined/None and let defaults apply) or make these fields explicitly required in the UI to match the validation behavior.

Copilot uses AI. Check for mistakes.
return value
Loading