<commit_before>import discord
from typing import List, Optional, Union
from necrobot.config import Config


client = None           # type: discord.Client
server = None           # type: discord.Server

main_channel = None     # type: discord.Channel
admin_roles = list()    # type: List[discord.Role]
staff_role = None       # type: Optional[discord.Role]


def init(client_: discord.Client, server_: discord.Server) -> None:
    global client, server, main_channel, admin_roles, staff_role
    client = client_
    server = server_
    main_channel = server.default_channel
    for rolename in Config.ADMIN_ROLE_NAMES:
        for role in server.roles:
            if role.name == rolename:
                admin_roles.append(role)
            if role.name == Config.STAFF_ROLE:
                staff_role = role


def find_admin(ignore=list()) -> Optional[discord.Member]:
    """Returns a random bot admin (for testing purposes)"""
    for member in server.members:
        if member.display_name in ignore or member.id == client.user.id:
            continue
        for role in member.roles:
            if role in admin_roles:
                return member
    return None


def find_channel(channel_name: str = None, channel_id: Union[str, int] = None) -> Optional[discord.Channel]:
    """Returns the channel with the given name on the server, if any"""
    if channel_id is not None:
        for channel in server.channels:
            if int(channel.id) == int(channel_id):
                return channel
    elif channel_name is not None:
        for channel in server.channels:
            if channel.name == channel_name:
                return channel
    return None


def find_member(discord_name: str = None, discord_id: Union[str, int] = None) -> Optional[discord.Member]:
    """Returns a member with a given username or ID (capitalization ignored)"""
    if discord_name is None and discord_id is None:
        return None

    if discord_id is not None:
        for member in server.members:
            if int(member.id) == int(discord_id):
                return member
    elif discord_name is not None:
        for member in server.members:
            if member.display_name.lower() == discord_name.lower() \
                    or member.name.lower() == discord_name.lower():
                return member


def find_members(username: str) -> List[discord.Member]:
    """Returns a list of all members with a given username (capitalization ignored)"""
    to_return = []
    for member in server.members:
        if member.display_name.lower() == username.lower():
            to_return.append(member)<commit_msg>fix capitalization checking on channel names<commit_after>import discord
from typing import List, Optional, Union
from necrobot.config import Config


client = None           # type: discord.Client
server = None           # type: discord.Server

main_channel = None     # type: discord.Channel
admin_roles = list()    # type: List[discord.Role]
staff_role = None       # type: Optional[discord.Role]


def init(client_: discord.Client, server_: discord.Server) -> None:
    global client, server, main_channel, admin_roles, staff_role
    client = client_
    server = server_
    main_channel = server.default_channel
    for rolename in Config.ADMIN_ROLE_NAMES:
        for role in server.roles:
            if role.name == rolename:
                admin_roles.append(role)
            if role.name == Config.STAFF_ROLE:
                staff_role = role


def find_admin(ignore=list()) -> Optional[discord.Member]:
    """Returns a random bot admin (for testing purposes)"""
    for member in server.members:
        if member.display_name in ignore or member.id == client.user.id:
            continue
        for role in member.roles:
            if role in admin_roles:
                return member
    return None


def find_channel(channel_name: str = None, channel_id: Union[str, int] = None) -> Optional[discord.Channel]:
    """Returns the channel with the given name on the server, if any"""
    if channel_id is not None:
        for channel in server.channels:
            if int(channel.id) == int(channel_id):
                return channel
    elif channel_name is not None:
        for channel in server.channels:
            if channel.name.lower() == channel_name.lower():
                return channel
    return None


def find_member(discord_name: str = None, discord_id: Union[str, int] = None) -> Optional[discord.Member]:
    """Returns a member with a given username or ID (capitalization ignored)"""
    if discord_name is None and discord_id is None:
        return None

    if discord_id is not None:
        for member in server.members:
            if int(member.id) == int(discord_id):
                return member
    elif discord_name is not None:
        for member in server.members:
            if member.display_name.lower() == discord_name.lower() \
                    or member.name.lower() == discord_name.lower():
                return member


def find_members(username: str) -> List[discord.Member]:
    """Returns a list of all members with a given username (capitalization ignored)"""
    to_return = []
    for member in server.members:
        if member.display_name.lower() == username.lower():
            to_return.append(member)
{'fraction_non_alphanumeric': 0.08857196472133609, 'fraction_numerical': 0.0, 'mean_word_length': 2.5019710906701706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '7430302', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1432, 'n_words': 482}