Exemplo n.º 1
0
    async def filter_manage_messages(self, ctx, value: bool = None):
        """
        Gets the current setting for whether manage message members are filter immune.
        If you're an administrator, you can change this value.
        """

        if value is None:
            filter_settings = self.bot.sql.filter.get_settings(ctx.guild)
            if filter_settings.manage_messages_immune:
                result = "**are filter immune**"
            else:
                result = "are **not** filter immune"

            embed = discord.Embed(colour=discord.Colour.dark_teal())
            embed.description = f"Those with the `Manage Messages` permission {result}."
        elif not admin_perm(ctx):
            # Lacking authority to set warn manual mod action
            embed = discord.Embed(colour=discord.Colour.red())
            embed.description = "You do not have permission to enable or disable manage messages filter immunity"
            raise ManualCheckFailure(embed=embed)
        else:
            with self.bot.sql.transaction():
                self.bot.sql.filter.set_bot_filter_immunity(
                    ctx.guild, manage_messages_immune=value)

            embed = discord.Embed(colour=discord.Colour.teal())
            embed.description = (
                f"Set filter immunity for those with manage messages to `{value}`"
            )

        await ctx.send(embed=embed)
Exemplo n.º 2
0
    async def reapply_auto(self, ctx, value: bool = None):
        """
        Tells whether automatic role reapplication is enabled.
        Only self-assignable and punishment roles are re-applied.
        If you're an administrator, you can change this value.
        """

        if value is None:
            # Get reapplication roles
            reapply = self.bot.sql.settings.get_auto_reapply(ctx.guild)
            embed = discord.Embed(colour=discord.Colour.dark_teal())
            enabled = "enabled" if reapply else "disabled"
            embed.description = (
                f"Automatic role reapplication is **{enabled}** on this server"
            )
        elif not admin_perm(ctx):
            # Lacking authority to set reapplication
            embed = discord.Embed(colour=discord.Colour.red())
            embed.description = (
                "You do not have permission to set automatic role reapplication"
            )
            raise ManualCheckFailure(embed=embed)
        else:
            # Set role reapplication
            with self.bot.sql.transaction():
                self.bot.sql.settings.set_auto_reapply(ctx.guild, value)

            embed = discord.Embed(colour=discord.Colour.dark_teal())
            embed.description = (
                f"{'Enabled' if value else 'Disabled'} automatic role reapplication"
            )

        await ctx.send(embed=embed)
Exemplo n.º 3
0
    async def warn_manual_mod_action(self, ctx, value: bool = None):
        """
        Gets the current setting for warning about manual mod actions.
        If you're an administrator, you can change this value.
        """

        if value is None:
            warn_manual_mod_action = self.bot.sql.settings.get_warn_manual_mod_action(
                ctx.guild)
            embed = discord.Embed(colour=discord.Colour.dark_teal())
            state = "enabled" if warn_manual_mod_action else "disabled"
            embed.description = f"Warning moderators about performing mod actions manually is **{state}**"
        elif not admin_perm(ctx):
            # Lacking authority to set warn manual mod action
            embed = discord.Embed(colour=discord.Colour.red())
            embed.description = "You do not have permission to enable or disable manual mod action warning"
            raise ManualCheckFailure(embed=embed)
        else:
            with self.bot.sql.transaction():
                self.bot.sql.settings.set_warn_manual_mod_action(
                    ctx.guild, value)

            embed = discord.Embed(colour=discord.Colour.teal())
            embed.description = f"Set warning moderators about performing mod actions manually to `{value}`"

        await ctx.send(embed=embed)
Exemplo n.º 4
0
    async def remove_other_roles_on_punish(self, ctx, value: bool = None):
        """
        Gets the current setting for whether punishment actions remove all other roles, or leaves them.
        If you're an administrator, you can change this value.
        """

        if value is None:
            remove_other_roles = self.bot.sql.settings.get_remove_other_roles(
                ctx.guild)
            embed = discord.Embed(colour=discord.Colour.dark_teal())
            state = "are removed" if remove_other_roles else "are kept"
            embed.description = (
                f"When punishment roles are added other roles **{state}**")
        elif not admin_perm(ctx):
            # Lacking authority to set remove other roles
            embed = discord.Embed(colour=discord.Colour.red())
            embed.description = "You do not have permissions to change the removal of non-punishment roles"
            raise ManualCheckFailure(embed=embed)
        else:
            with self.bot.sql.transaction():
                self.bot.sql.settings.set_remove_other_roles(ctx.guild, value)

            embed = discord.Embed(colour=discord.Colour.teal())
            embed.description = (
                f"Set removal of other non-punishment roles to `{value}`")

        await ctx.send(embed=embed)
Exemplo n.º 5
0
    async def max_delete(self, ctx, count: int = None):
        """
        Gets the current setting for maximum messages to bulk delete.
        If you're an administrator, you can change this value.
        """

        if count is None:
            # Get max delete messages
            max_delete_messages = self.bot.sql.settings.get_max_delete_messages(
                ctx.guild)
            embed = discord.Embed(colour=discord.Colour.dark_teal())
            embed.description = f"Maximum number of messages that can be deleted in bulk is `{max_delete_messages}`"
        elif not admin_perm(ctx):
            # Lacking authority to set max delete messages
            embed = discord.Embed(colour=discord.Colour.red())
            embed.description = (
                "You do not have permission to set the maximum deletable messages"
            )
            raise ManualCheckFailure(embed=embed)
        elif count <= 0:
            # Negative value
            embed = discord.Embed(colour=discord.Colour.red())
            embed.description = "This value must be a positive, non-zero integer"
            raise CommandFailed(embed=embed)
        elif count >= 2**32 - 1:
            # Over a sane upper limit
            embed = discord.Embed(colour=discord.Colour.red())
            embed.description = (
                "This value is way too high. Try a more reasonable value.")
            raise CommandFailed(embed=embed)
        else:
            # Set max delete messages
            with self.bot.sql.transaction():
                self.bot.sql.settings.set_max_delete_messages(ctx.guild, count)

            embed = discord.Embed(colour=discord.Colour.dark_teal())
            embed.description = f"Set maximum deletable messages to `{count}`"

        await ctx.send(embed=embed)