Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a cog to manage tracking a user's alt accounts #2845

Merged
merged 8 commits into from
May 23, 2024

Conversation

ChrisLovering
Copy link
Member

@ChrisLovering ChrisLovering commented Dec 13, 2023

Important note

This must be merged after python-discord/site#1171

Summary

This allows moderators, in mod channels, to add, remove & list a user's alt accounts.

When searching for infractions by user id, the number of al accounts is also shown, if there are any.

Screenshot

Wording can be discussed...
image

@ChrisLovering ChrisLovering added t: feature New feature or request a: API Related to or causes API changes a: moderation Related to community moderation functionality: (moderation, defcon, verification) s: needs review Author is waiting for someone to review and approve review: do not merge The PR can be reviewed but cannot be merged now labels Dec 13, 2023
@ChrisLovering ChrisLovering force-pushed the feat/1353/alt-users branch 2 times, most recently from f915536 to 1152d3c Compare December 15, 2023 12:00
return str(error.response_json)
return error.response_text

async def alts_to_string(self, alts: list[dict[str: str | int | list[int]]]) -> list[str]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always think it's better to have a local pydantic model that explains the structure, instead of a lot of nested types likes this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to leave it as list[dict] but thought I might as well expand it further. Didn't want to make a full model since site might change and I don't want ot have to maintain it in two places

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you have to maintain it in 2 places ?
Reading this as it is is "painful" and one would need to squeeze their toughts in order to understand what's going on, and it isn't pleasant. Giving it structure would be more readable/intuitive/understandable.

Copy link
Contributor

@wookie184 wookie184 Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the current type isn't very useful ,str | int | list[int] makes the usages below technically incorrect since whenever accessing a value they should handle it being any of those types.

I would be find with any of these, since they're all "correct", it just depends what you consider in-scope for the PR given our typing elsewhere with infractions isn't great either afaik:

  1. list[dict[str, typing.Any]] or list[dict]
  2. Use a TypedDict
  3. Use a Pydantic model

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified the type annotation in a380d2e (option 1)

bot/exts/moderation/alts.py Show resolved Hide resolved
bot/exts/moderation/alts.py Show resolved Hide resolved
bot/exts/moderation/alts.py Show resolved Hide resolved
bot/exts/moderation/infraction/management.py Show resolved Hide resolved
bot/exts/moderation/alts.py Show resolved Hide resolved
return str(error.response_json)
return error.response_text

async def alts_to_string(self, alts: list[dict[str: str | int | list[int]]]) -> list[str]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you have to maintain it in 2 places ?
Reading this as it is is "painful" and one would need to squeeze their toughts in order to understand what's going on, and it isn't pleasant. Giving it structure would be more readable/intuitive/understandable.

bot/exts/moderation/alts.py Show resolved Hide resolved
@@ -337,6 +338,12 @@ async def create_user_embed(self, ctx: Context, user: MemberOrUser, passed_as_me

return embed

async def user_alt_count(self, user: MemberOrUser) -> tuple[str, int | str]:
"""Get the number oif alts for the given member."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itty bitty typo oif -> of

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just his accent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have corrected my accent in 98eea89

@wookie184 wookie184 linked an issue Apr 14, 2024 that may be closed by this pull request
@wookie184 wookie184 added s: waiting for author Waiting for author to address a review or respond to a comment and removed s: needs review Author is waiting for someone to review and approve labels Apr 16, 2024
@wookie184 wookie184 removed the s: waiting for author Waiting for author to address a review or respond to a comment label May 20, 2024
@ChrisLovering ChrisLovering merged commit daeb4bd into main May 23, 2024
4 of 5 checks passed
@ChrisLovering ChrisLovering deleted the feat/1353/alt-users branch May 23, 2024 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: API Related to or causes API changes a: moderation Related to community moderation functionality: (moderation, defcon, verification) review: do not merge The PR can be reviewed but cannot be merged now t: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a better system for keeping track of alternate accounts
7 participants