def get_last_message(client, chan, uid=None):
    """
    Search through the client's messages to find the last message
    Can also add a User ID to get a specific user's messages
    """
    if len(client.messages) == 0:
        raise Exception("How are we even here?")
    if len(client.messages) == 1:
        return None
    c_uid = lambda u, v: True
    if uid is not None:
        c_uid = lambda u, v: u == v
    res = [msg for msg in client.messages
            if msg.channel == chan
            and msg.author.id != client.user.id
            and c_uid(uid, msg.author.id)]
    if len(res) <= 1:
        return None
    return res[-2]