Skip to content

case_service

Case service for moderation operations.

This service handles case creation, retrieval, and management using the existing database controllers and proper dependency injection.

Classes:

  • CaseService

    Service for managing moderation cases.

Classes

CaseService

Python
CaseService(case_controller: CaseController)

Service for managing moderation cases.

Provides clean, testable methods for case operations without the complexity of mixin inheritance.

Initialize the case service.

Parameters:

  • case_controller (CaseController) –

    Database controller for case operations.

Methods:

Functions

create_case async
Python
create_case(
    guild_id: int,
    user_id: int,
    moderator_id: int,
    case_type: CaseType,
    reason: str,
    **kwargs: Any,
) -> Case

Create a new moderation case.

Parameters:

  • guild_id (int) –

    ID of the guild.

  • user_id (int) –

    ID of the target user.

  • moderator_id (int) –

    ID of the moderator.

  • case_type (CaseType) –

    Type of moderation action.

  • reason (str) –

    Reason for the action.

  • **kwargs (Any, default: {} ) –

    Additional case data (use case_expires_at for expiration datetime).

Returns:

  • Case

    The created case.

get_case async
Python
get_case(case_id: int) -> Case | None

Get a case by ID.

Parameters:

  • case_id (int) –

    The case ID to retrieve.

Returns:

  • Case | None

    The case if found, None otherwise.

get_user_cases async
Python
get_user_cases(user_id: int, guild_id: int) -> list[Case]

Get all cases for a user in a guild.

Parameters:

  • user_id (int) –

    The user ID.

  • guild_id (int) –

    The guild ID.

Returns:

  • list[Case]

    List of cases for the user.

get_active_cases async
Python
get_active_cases(user_id: int, guild_id: int) -> list[Case]

Get active cases for a user in a guild.

Parameters:

  • user_id (int) –

    The user ID.

  • guild_id (int) –

    The guild ID.

Returns:

  • list[Case]

    List of active cases for the user.

update_mod_log_message_id async
Python
update_mod_log_message_id(case_id: int, message_id: int) -> Case | None

Update the mod log message ID for a case.

Parameters:

  • case_id (int) –

    The case ID to update.

  • message_id (int) –

    The Discord message ID from the mod log.

Returns:

  • Case | None

    The updated case, or None if not found.