def get_guild_id(guild):
    try:
        guild_id = int(guild['id'])
    except:
        query = ('    \n            {\n            guildData{\n                guild(name: "%s", serverSlug: "%s", serverRegion: "%s"){\n                id\n                }\n            }\n            }\n        ' % (guild['name'], guild['realm'].replace(' ', '-'), guild['region']))
        r = requests.post(graphql_endpoint, json={'query': query}, headers=headers)
        guild_id = r.json()['data']['guildData']['guild']['id']
    return guild_id
def get_guild_id(guild):
    try:
        guild_id = int(guild['id'])
    except:
        query = ('    \n            {\n            guildData{\n                guild(name: "%s", serverSlug: "%s", serverRegion: "%s"){\n                id\n                }\n            }\n            }\n        ' % (guild['name'], guild['realm'].replace(' ', '-'), guild['region']))
        r = requests.post(graphql_endpoint, json={'query': query}, headers=headers)
        guild_id = r.json()['data']['guildData']['guild']['id']
    return guild_id