import json


def get_feed_by_guild(guild, *, return_path=False):
    """Get all feeds in a certain guild

    Args:
        guild (number): the guild ID (int() is used on it so string is fine too)
        return_path (boolean): whether it should return the path to the database entry instead of the entry directly (defaults to False)
    Returns:
        sends a list of all "channels" objects that matched from the database, in addition it adds a 'url' string to all of them
    """
    guild = int(guild)
    results = []
    feeds = json.load(open('settings/database.json', 'r'))['feeds']

    f_count = 0

    for f in feeds:
        c_count = 0
        for c in f['channels']:
            if c['guildID'] == guild:
                if return_path == True:
                    results.append(f'{f_count}-{c_count}')
                else:
                    c['url'] = f['url']
                    results.append(c)
            c_count += 1
        f_count += 1

    return results