Skip to content

Commit

Permalink
Revert "Handle the ints for user objects in Modlog appropriately (#3784
Browse files Browse the repository at this point in the history
…)" (#3802)

This reverts commit e595f18.
  • Loading branch information
Kowlin authored Apr 28, 2020
1 parent ca1f39a commit ef35fc0
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions redbot/core/modlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ def __init__(
created_at: int,
action_type: str,
user: Union[discord.User, int],
moderator: Optional[Union[discord.User, int]],
moderator: discord.User,
case_number: int,
reason: str = None,
until: int = None,
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, int]] = None,
amended_by: Optional[Union[discord.User, int]] = None,
amended_by: Optional[discord.User] = None,
modified_at: Optional[int] = None,
message: Optional[discord.Message] = None,
last_known_username: Optional[str] = None,
Expand Down Expand Up @@ -294,12 +294,10 @@ async def message_content(self, embed: bool = True):
else:
reason = _("**Reason:** Use the `reason` command to add it")

if self.moderator is None:
moderator = _("Unknown")
elif isinstance(self.moderator, int):
moderator = f"[Unknown or Deleted User] ({self.moderator})"
else:
if self.moderator is not None:
moderator = escape_spoilers(f"{self.moderator} ({self.moderator.id})")
else:
moderator = _("Unknown")
until = None
duration = None
if self.until:
Expand All @@ -311,12 +309,13 @@ async def message_content(self, embed: bool = True):
until = end_fmt
duration = dur_fmt

amended_by = None
if self.amended_by:
amended_by = None
elif isinstance(self.amended_by, int):
amended_by = f"[Unknown or Deleted User] ({self.amended_by})"
else:
amended_by = escape_spoilers(f"{self.amended_by} ({self.amended_by.id})")
amended_by = escape_spoilers(
"{}#{} ({})".format(
self.amended_by.name, self.amended_by.discriminator, self.amended_by.id
)
)

last_modified = None
if self.modified_at:
Expand Down Expand Up @@ -384,14 +383,10 @@ def to_json(self) -> dict:
The case in the form of a dict
"""
if self.moderator is None or isinstance(self.moderator, int):
mod = self.moderator
else:
if self.moderator is not None:
mod = self.moderator.id
if self.amended_by is None or isinstance(self.amended_by, int):
amended_by = self.amended_by
else:
amended_by = self.amended_by.id
mod = None
if isinstance(self.user, int):
user_id = self.user
else:
Expand All @@ -407,7 +402,7 @@ def to_json(self) -> dict:
"reason": self.reason,
"until": self.until,
"channel": self.channel.id if hasattr(self.channel, "id") else None,
"amended_by": amended_by,
"amended_by": self.amended_by.id if hasattr(self.amended_by, "id") else None,
"modified_at": self.modified_at,
"message": self.message.id if hasattr(self.message, "id") else None,
}
Expand Down

0 comments on commit ef35fc0

Please sign in to comment.