Skip to content

Commit e4d1aba

Browse files
committed
Add timestamp to automod/command alerts
1 parent 174c4cb commit e4d1aba

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

techsupport_bot/core/moderation.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""This file will hold the core moderation functions. These functions will:
22
Do the proper moderative action and return true if successful, false if not."""
33

4-
from datetime import timedelta
4+
import datetime
55

66
import discord
77
import munch
@@ -64,13 +64,15 @@ async def kick_user(guild: discord.Guild, user: discord.Member, reason: str) ->
6464
return True
6565

6666

67-
async def mute_user(user: discord.Member, reason: str, duration: timedelta) -> bool:
67+
async def mute_user(
68+
user: discord.Member, reason: str, duration: datetime.timedelta
69+
) -> bool:
6870
"""Times out a given user
6971
7072
Args:
7173
user (discord.Member): The user to timeout
7274
reason (str): The reason they are being timed out
73-
duration (timedelta): How long to timeout the user for
75+
duration (datetime.timedelta): How long to timeout the user for
7476
7577
Returns:
7678
bool: True if the timeout was successful
@@ -253,6 +255,7 @@ async def send_command_usage_alert(
253255

254256
embed.set_thumbnail(url=ALERT_ICON_URL)
255257
embed.color = discord.Color.red()
258+
embed.timestamp = datetime.datetime.utcnow()
256259

257260
await alert_channel.send(embed=embed)
258261

techsupport_bot/functions/automod.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import datetime
56
import re
67
from dataclasses import dataclass
78
from datetime import timedelta
@@ -216,7 +217,7 @@ async def response(
216217
await moderation.mute_user(
217218
user=ctx.author,
218219
reason=total_punishment.violation_string,
219-
duration=timedelta(seconds=total_punishment.mute_duration),
220+
duration=datetime.timedelta(seconds=total_punishment.mute_duration),
220221
)
221222

222223
if total_punishment.delete_message:
@@ -445,6 +446,7 @@ def generate_automod_alert_embed(
445446

446447
embed.set_thumbnail(url=ALERT_ICON_URL)
447448
embed.color = discord.Color.red()
449+
embed.timestamp = datetime.datetime.utcnow()
448450

449451
return embed
450452

0 commit comments

Comments
 (0)