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

this implementation is flawed, if someone bans and unbans the same user multiple times, this will not work as expected... #588

Open
github-actions bot opened this issue Sep 30, 2024 · 0 comments

Comments

@github-actions
Copy link
Contributor

) # TODO: this implementation is flawed, if someone bans and unbans the same user multiple times, this will not work as expected

class Poll(commands.Cog):
    def __init__(self, bot: Tux) -> None:
        self.bot = bot
        self.case_controller = CaseController()

    # TODO: for the moment this is duplicated code from ModerationCogBase in a attempt to get the code out sooner
    async def is_pollbanned(self, guild_id: int, user_id: int) -> bool:
        """
        Check if a user is poll banned.

        Parameters
        ----------
        guild_id : int
            The ID of the guild to check in.
        user_id : int
            The ID of the user to check.

        Returns
        -------
        bool
            True if the user is poll banned, False otherwise.
        """

        ban_cases = await self.case_controller.get_all_cases_by_type(guild_id, CaseType.POLLBAN)
        unban_cases = await self.case_controller.get_all_cases_by_type(guild_id, CaseType.POLLUNBAN)

        ban_count = sum(case.case_user_id == user_id for case in ban_cases)
        unban_count = sum(case.case_user_id == user_id for case in unban_cases)

        return (
            ban_count > unban_count
        )  # TODO: this implementation is flawed, if someone bans and unbans the same user multiple times, this will not work as expected

    @commands.Cog.listener()  # listen for messages
    async def on_message(self, message: discord.Message) -> None:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants