def remove_custom_guild_options(self, guild_id: int) -> None:
        """
        Reset a guilds options to the ASH options

        Parameters
        ----------
        guild_id : int
            The guild to reset

        Warnings
        --------
        If using ``AntiSpamTracker``, please call this
        method on that class instance. Not this one.

        Notes
        -----
        This method will silently ignore guilds that
        do not exist, as it is considered to have
        'removed' custom options due to how Guild's
        are created

        This is also a somewhat expensive operation at ``O(n)``
        where ``n`` is the total number of users cached for the guild
        """
        guild = Guild(self.bot, guild_id, self.options)
        try:
            guild = next(iter(g for g in self.guilds if g == guild))
        except StopIteration:
            pass
        else:
            guild.options = self.options
            guild.has_custom_options = False

            log.debug(f"Reset guild options for {guild_id}")
Example #2
0
    def remove_custom_guild_options(self, guild_id: int) -> None:
        """
        Reset a guilds options to the ASH options

        Parameters
        ----------
        guild_id : int
            The guild to reset

        Notes
        -----
        This method will silently ignore guilds that
        do not exist, as it is considered to have
        'removed' custom options due to how Guild's
        are created

        """
        guild = Guild(self.bot, guild_id, self.options, logger=logging)
        try:
            guild = next(iter(g for g in self.guilds if g == guild))
        except StopIteration:
            pass
        else:
            guild.options = self.options
            guild.has_custom_options = False
    def remove_custom_guild_options(self, guild_id: int) -> None:
        """
        Reset a guilds options to the ASH options

        Parameters
        ----------
        guild_id : int
            The guild to reset

        Warnings
        --------
        If using ``AntiSpamTracker``, please call this
        method on that class instance. Not this one.

        Notes
        -----
        This method will silently ignore guilds that
        do not exist, as it is considered to have
        'removed' custom options due to how Guild's
        are created

        """
        guild = Guild(self.bot, guild_id, self.options)
        try:
            guild = next(iter(g for g in self.guilds if g == guild))
        except StopIteration:
            pass
        else:
            guild.options = self.options
            guild.has_custom_options = False
    def add_custom_guild_options(self, guild_id: int, **kwargs):
        """
        Set a guild's options to a custom set, rather then the base level
        set used and defined in ASH initialization

        Parameters
        ----------
        guild_id : int
            The id of the guild to create
        warn_threshold : int, optional
            This is the amount of messages in a row that result in a warning within the message_interval
        kick_threshold : int, optional
            The amount of 'warns' before a kick occurs
        ban_threshold : int, optional
            The amount of 'kicks' that occur before a ban occurs
        message_interval : int, optional
            Amount of time a message is kept before being discarded.
            Essentially the amount of time (In milliseconds) a message can count towards spam
        guild_warn_message : Union[str, dict], optional
            The message to be sent in the guild upon warn_threshold being reached
        guild_kick_message : Union[str, dict], optional
            The message to be sent in the guild upon kick_threshold being reached
        guild_ban_message : Union[str, dict], optional
            The message to be sent in the guild upon ban_threshold being reached
        user_kick_message : Union[str, dict], optional
            The message to be sent to the user who is being warned
        user_ban_message : Union[str, dict], optional
            The message to be sent to the user who is being banned
        user_failed_kick_message : Union[str, dict], optional
            The message to be sent to the user if the bot fails to kick them
        user_failed_ban_message : Union[str, dict], optional
            The message to be sent to the user if the bot fails to ban them
        message_duplicate_count : int, optional
            Amount of duplicate messages needed to trip a punishment
        message_duplicate_accuracy : float, optional
            How 'close' messages need to be to be registered as duplicates (Out of 100)
        delete_spam : bool, optional
            Whether or not to delete any messages marked as spam
        ignore_perms : list, optional
            The perms (ID Form), that bypass anti-spam
        ignore_channels : list, optional
            The channels (ID Form) that are ignored
        ignore_roles : list, optional
            The roles (ID, Name) that are ignored
        ignore_guilds : list, optional
            The guilds (ID) that are ignored
        ignore_users : list, optional
            The users (ID Form), that bypass anti-spam
        ignore_bots : bool, optional
            Should bots bypass anti-spam?
        warn_only : bool, optional
            Only warn users?
        no_punish : bool, optional
            Dont punish users?
            Return if they should be punished or
            not without actually punishing them
        per_channel_spam : bool, optional
            Track spam as per channel,
            rather then per guild
        guild_warn_message_delete_after : int, optional
            The time to delete the ``guild_warn_message`` message
        user_kick_message_delete_after : int, optional
            The time to delete the ``user_kick_message`` message
        guild_kick_message_delete_after : int, optional
            The time to delete the ``guild_kick_message`` message
        user_ban_message_delete_after : int, optional
            The time to delete the ``user_ban_message`` message
        guild_ban_message_delete_after : int, optional
            The time to delete the ``guild_ban_message`` message

        Warnings
        --------
        If using ``AntiSpamTracker``, please call this
        method on that class instance. Not this one.

        Notes
        =====
        This will override any current settings, if you wish
        to continue using existing settings and merely change some
        I suggest using the get_options method first and then giving
        those values back to this method with the changed arguments

        This is also a somewhat expensive operation at ``O(n)``
        where ``n`` is the total number of users cached for the guild
        """
        options = self._ensure_options(**kwargs)

        guild = Guild(self.bot, guild_id, options, custom_options=True)
        try:
            guild = next(iter(g for g in self.guilds if g == guild))
        except StopIteration:
            log.warning(
                f"I cannot ensure I have permissions to kick/ban ban people in guild: {guild_id}"
            )

            self.guilds = guild
            log.info(f"Created Guild: {guild.id}")
        else:
            guild.options = options
            guild.has_custom_options = True

        log.info(f"Set custom options for guild: {guild_id}")