<commit_before>import asyncio
import discord
import re
from   discord.ext import commands
from   Cogs import Nullify

def setup(bot):
	# This module isn't actually a cog
    return

def name(member : discord.Member):
    # A helper function to return the member's display name
    nick = name = None
    try:
        nick = member.nick
    except AttributeError:
        pass
    try:
        name = member.name
    except AttributeError:
        pass
    if nick:
        return Nullify.clean(nick)
    if name:
        return Nullify.clean(name)
    return None

def memberForID(checkid, server):
    for member in server.members:
        if str(member.id) == str(checkid):
            return member
    return None

def memberForName(name, server):
    # Check nick first - then name
    name = str(name)
    for member in server.members:
        if member.nick:
            if member.nick.lower() == name.lower():
                return member
    for member in server.members:
        if member.name.lower() == name.lower():
            return member
    memID = re.sub(r'\W+', '', name)
    newMem = memberForID(memID, server)
    if newMem:
        return newMem
    return None

def channelForID(id, server, typeCheck = None):
    for channel in server.channels:
        if typeCheck:
            if typeCheck.lower() == "text" and not type(channel) is discord.TextChannel:
                continue
            if typeCheck.lower() == "voice" and not type(channel) is discord.VoiceChannel:
                continue
        if str(channel.id) == str(id):
            return channel
    return None

def channelForName(name, server, typeCheck = None):
    name = str(name)
    for channel in server.channels:
        if typeCheck:
            if typeCheck.lower() == "text" and not type(channel) is discord.TextChannel:
                continue
            if typeCheck.lower() == "voice" and not type(channel) is discord.VoiceChannel:
                continue
        if channel.name.lower() == name.lower():
            return channel
    chanID = re.sub(r'\W+', '', name)
    newChan = channelForID(chanID, server, typeCheck)
    if newChan:
        return newChan
    return None

def roleForID(id, server):
    for role in server.roles:
        if str(role.id) == str(id):
            return role
    return None

def roleForName(name, server):<commit_msg>Attempts at better id handling<commit_after>import asyncio
import discord
import re
from   discord.ext import commands
from   Cogs import Nullify

def setup(bot):
	# This module isn't actually a cog
    return

def name(member : discord.Member):
    # A helper function to return the member's display name
    nick = name = None
    try:
        nick = member.nick
    except AttributeError:
        pass
    try:
        name = member.name
    except AttributeError:
        pass
    if nick:
        return Nullify.clean(nick)
    if name:
        return Nullify.clean(name)
    return None

def memberForID(checkid, server):
    try:
        checkid = int(checkid)
    except:
        return None
    for member in server.members:
        if member.id == checkid:
            return member
    return None

def memberForName(name, server):
    # Check nick first - then name
    name = str(name)
    for member in server.members:
        if member.nick:
            if member.nick.lower() == name.lower():
                return member
    for member in server.members:
        if member.name.lower() == name.lower():
            return member
    memID = re.sub(r'\W+', '', name)
    newMem = memberForID(memID, server)
    if newMem:
        return newMem
    return None

def channelForID(checkid, server, typeCheck = None):
    try:
        checkid = int(checkid)
    except:
        return None
    for channel in server.channels:
        if typeCheck:
            if typeCheck.lower() == "text" and not type(channel) is discord.TextChannel:
                continue
            if typeCheck.lower() == "voice" and not type(channel) is discord.VoiceChannel:
                continue
        if channel.id == checkid:
            return channel
    return None

def channelForName(name, server, typeCheck = None):
    name = str(name)
    for channel in server.channels:
        if typeCheck:
            if typeCheck.lower() == "text" and not type(channel) is discord.TextChannel:
                continue
            if typeCheck.lower() == "voice" and not type(channel) is discord.VoiceChannel:
                continue
        if channel.name.lower() == name.lower():
            return channel
    chanID = re.sub(r'\W+', '', name)
    newChan = channelForID(chanID, server, typeCheck)
    if newChan:
        return newChan
    return None

def roleForID(checkid, server):
    try:
        checkid = int(checkid)
    except:
        return None
    for role in server.roles:
        if role.id == checkid:
            return role
    return None

def roleForName(name, server):
{'fraction_non_alphanumeric': 0.08896509985878556, 'fraction_numerical': 0.0, 'mean_word_length': 2.1221662468513856, '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': '3993561', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1380, 'n_words': 457}