communication_service ¶
Communication service for moderation operations.
Handles DM sending, embed creation, and user communication without the complexity of mixin inheritance.
Classes:
-
CommunicationService–Service for handling moderation-related communication.
Classes¶
CommunicationService ¶
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:
-
send_dm–Send a DM to a user about a moderation action.
-
send_error_response–Send an error response to the user.
-
create_embed–Create a moderation embed.
-
send_embed–Send an embed and optionally log it.
-
send_audit_log_embed–Send an embed to the audit log channel.
-
send_mod_log_embed–Send an embed to the mod log channel.
Functions¶
send_dm async ¶
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 ¶
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 ¶
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.