<commit_before>import discord
from discord.ext.commands import guild_only, bot_has_permissions, has_permissions
from lifesaver.bot import Cog, command, Context

from dog.converters import SoftMember
from dog.formatting import represent


class Mod(Cog):
    """Moderation-related commands."""
    @command()
    @guild_only()
    @bot_has_permissions(ban_members=True)
    @has_permissions(ban_members=True)
    async def ban(self, ctx: Context, target: SoftMember, *, reason):
        """Bans someone."""
        try:
            reason = f'Banned by {represent(ctx.author)}: {reason or "No reason."}'
            await ctx.guild.ban(target, reason=reason)
        except discord.Forbidden:
            await ctx.send(f"I can't ban {target}.")
        else:
            await ctx.send(f'\N{OK HAND SIGN} Banned {represent(target)}.')

    @command()
    @guild_only()
    @bot_has_permissions(ban_members=True)
    @has_permissions(ban_members=True)
    async def softban(self, ctx: Context, target: discord.Member, *, reason):
        """Bans then immediately unbans someone."""
        try:
            reason = f'Softbanned by {represent(ctx.author)}: {reason or "No reason."}'
            await target.ban(reason=reason)
            await target.unban(reason=reason)
        except discord.Forbidden:
            await ctx.send(f"I can't ban {target}.")
        else:
            await ctx.send(f'\N{OK HAND SIGN} Softbanned {represent(target)}.')<commit_msg>mod: port vanity role command<commit_after>import discord
from discord.ext.commands import bot_has_permissions, guild_only, has_permissions
from lifesaver.bot import Cog, Context, command
from lifesaver.utils import escape_backticks

from dog.converters import SoftMember
from dog.formatting import represent


class Mod(Cog):
    """Moderation-related commands."""
    @command()
    @guild_only()
    @bot_has_permissions(ban_members=True)
    @has_permissions(ban_members=True)
    async def ban(self, ctx: Context, target: SoftMember, *, reason):
        """Bans someone."""
        try:
            reason = f'Banned by {represent(ctx.author)}: {reason or "No reason."}'
            await ctx.guild.ban(target, reason=reason)
        except discord.Forbidden:
            await ctx.send(f"I can't ban {target}.")
        else:
            await ctx.send(f'\N{OK HAND SIGN} Banned {represent(target)}.')

    @command()
    @guild_only()
    @bot_has_permissions(manage_roles=True)
    @has_permissions(manage_roles=True)
    async def vanity(self, ctx: Context, name, color: discord.Color = None, *targets: discord.Member):
        """Creates a vanity role."""
        try:
            role = await ctx.guild.create_role(
                name=name,
                color=color or discord.Color.default(),
                permissions=discord.Permissions.none(),
                reason=f'Vanity role created by {represent(ctx.author)}'
            )
        except discord.HTTPException as error:
            await ctx.send(f'Failed to create vanity role. Error: `{error}`')
            return

        if not targets:
            await ctx.ok()
            return

        name = escape_backticks(role.name)
        ctx.new_paginator(prefix='', suffix='')
        ctx += f'\U00002705 Created vanity role `{name}`.'

        for target in targets:
            try:
                await target.add_roles(role, reason=f'Vanity role auto-assign by {represent(ctx.author)}')
            except discord.HTTPException as error:
                ctx += f'\N{CROSS MARK} Failed to add `{name}` to {represent(target)}: {error}'
            else:
                ctx += f'\U00002705 Added `{name}` to {represent(target)}.'

        await ctx.send_pages()

    @command()
    @guild_only()
    @bot_has_permissions(ban_members=True)
    @has_permissions(ban_members=True)
    async def softban(self, ctx: Context, target: discord.Member, *, reason):
        """Bans then immediately unbans someone."""
        try:
            reason = f'Softbanned by {represent(ctx.author)}: {reason or "No reason."}'
            await target.ban(reason=reason)
            await target.unban(reason=reason)
        except discord.Forbidden:
            await ctx.send(f"I can't ban {target}.")
        else:
            await ctx.send(f'\N{OK HAND SIGN} Softbanned {represent(target)}.')
{'fraction_non_alphanumeric': 0.11988911988911989, 'fraction_numerical': 0.003696003696003696, 'mean_word_length': 2.6601859678782755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4351445', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1280, 'n_words': 324}