Surely there's a better way to do this...

def channel_to_id(slack, channel):
    """ Surely there's a better way to do this... """
    channels = slack.api_call('channels.list').get('channels') or []
    groups = slack.api_call('groups.list').get('groups') or []

    if not channels and not groups:
        raise RuntimeError("Couldn't get channels and groups.")

    ids = [c['id'] for c in channels + groups if c['name'] == channel]

    if not ids:
        raise ValueError(f"Couldn't find #{channel}")

    return ids[0]