aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-09-26 20:28:31 -0700
committerGravatar MarkKoz <[email protected]>2019-10-01 18:25:31 -0700
commit7a15665079fb9d31bf27e2a23600b42fb7758ed6 (patch)
tree2635451c198e2543562692ce3e8f621dffcbaecc
parentAdd type alias for infraction objects (diff)
Use None for default values for notify_infraction's parameters
These adjustments make it easier to call the function using values directly from the infraction object as arguments. * Set actual default values inside the function if values are None * Accept only a string for expires_at
-rw-r--r--bot/cogs/moderation.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py
index 90c1ad339..3162a9a5d 100644
--- a/bot/cogs/moderation.py
+++ b/bot/cogs/moderation.py
@@ -2,7 +2,7 @@ import asyncio
import logging
import textwrap
from datetime import datetime
-from typing import Dict, Iterable, Union
+from typing import Dict, Iterable, Optional, Union
from discord import (
Colour, Embed, Forbidden, Guild, HTTPException, Member, NotFound, Object, User
@@ -976,22 +976,21 @@ class Moderation(Scheduler, Cog):
self,
user: Union[User, Member],
infr_type: str,
- expires_at: Union[datetime, str] = 'N/A',
- reason: str = "No reason provided."
+ expires_at: Optional[str] = None,
+ reason: Optional[str] = None
) -> bool:
"""
Attempt to notify a user, via DM, of their fresh infraction.
Returns a boolean indicator of whether the DM was successful.
"""
- if isinstance(expires_at, datetime):
- expires_at = expires_at.strftime(INFRACTION_FORMAT)
+ expires_at = format_infraction(expires_at) if expires_at else "N/A"
embed = Embed(
description=textwrap.dedent(f"""
**Type:** {infr_type}
**Expires:** {expires_at}
- **Reason:** {reason}
+ **Reason:** {reason or "No reason provided."}
"""),
colour=Colour(Colours.soft_red)
)