Skip to content

communication_service

Communication service for moderation operations.

Handles DM sending, embed creation, and user communication without the complexity of mixin inheritance.

Classes:

Classes

CommunicationService

Python
CommunicationService(bot: Tux)

Service for handling moderation-related communication.

Manages DM sending, embed creation, and user notifications with proper error handling and timeouts.

Initialize the communication service.

Parameters:

  • bot (Tux) –

    The Discord bot instance.

Methods:

Functions

send_dm async
Python
send_dm(
    ctx: Context[Tux], silent: bool, user: Member | User, reason: str, dm_action: str
) -> bool

Send a DM to a user about a moderation action.

Parameters:

  • ctx (Context[Tux]) –

    Command context.

  • silent (bool) –

    Whether to send DM (if False, returns False immediately).

  • user (Member | User) –

    Target user.

  • reason (str) –

    Reason for the action.

  • dm_action (str) –

    Action description for DM.

Returns:

  • bool

    True if DM was sent successfully, False otherwise.

send_error_response async
Python
send_error_response(
    ctx: Context[Tux] | Interaction, message: str, ephemeral: bool = True
) -> None

Send an error response to the user.

Parameters:

  • ctx (Context[Tux] | Interaction) –

    Command context.

  • message (str) –

    Error message to send.

  • ephemeral (bool, default: True ) –

    Whether the response should be ephemeral, by default True.

create_embed
Python
create_embed(
    ctx: Context[Tux],
    title: str,
    fields: list[tuple[str, str, bool]],
    color: int,
    icon_url: str,
    timestamp: datetime | None = None,
    thumbnail_url: str | None = None,
) -> Embed

Create a moderation embed.

Parameters:

  • ctx (Context[Tux]) –

    Command context.

  • title (str) –

    Embed title.

  • fields (list[tuple[str, str, bool]]) –

    List of (name, value, inline) tuples.

  • color (int) –

    Embed color.

  • icon_url (str) –

    Icon URL for the embed.

  • timestamp (datetime | None, default: None ) –

    Optional timestamp, by default None.

  • thumbnail_url (str | None, default: None ) –

    Optional thumbnail URL, by default None.

Returns:

  • Embed

    The created embed.

send_embed async
Python
send_embed(ctx: Context[Tux], embed: Embed, log_type: str = 'mod') -> Message | None

Send an embed and optionally log it.

Parameters:

  • ctx (Context[Tux]) –

    Command context.

  • embed (Embed) –

    The embed to send.

  • log_type (str, default: 'mod' ) –

    Type of log entry, by default "mod".

Returns:

  • Message | None

    The sent message if successful.

send_audit_log_embed async
Python
send_audit_log_embed(ctx: Context[Tux], embed: Embed) -> Message | None

Send an embed to the audit log channel.

Parameters:

  • ctx (Context[Tux]) –

    Command context.

  • embed (Embed) –

    The embed to send to audit log.

Returns:

  • Message | None

    The sent audit log message if successful, None otherwise.

send_mod_log_embed async
Python
send_mod_log_embed(ctx: Context[Tux], embed: Embed) -> Message | None

Send an embed to the mod log channel.

Parameters:

  • ctx (Context[Tux]) –

    Command context.

  • embed (Embed) –

    The embed to send to mod log.

Returns:

  • Message | None

    The sent mod log message if successful, None otherwise.

_create_dm_embed
Python
_create_dm_embed(action: str, reason: str, moderator: User) -> Embed

Create a DM embed for moderation actions.

Parameters:

  • action (str) –

    The action that was taken.

  • reason (str) –

    Reason for the action.

  • moderator (User) –

    The moderator who performed the action.

Returns:

  • Embed

    The DM embed.