Ejemplo n.º 1
0
def charSearch(charName):
    query = searchChar()
    variables = GetByChar(charName)
    if variables:
        result = run_query(query, variables)
        if not result:
            return discord.Embed(
                description="There does not exist a character with the name {}."
                .format(charName))

        embed = discord.Embed(
            colour=discord.Colour.dark_orange(),
            title=result["data"]["Character"]["name"]["full"],
            url=result["data"]["Character"]["siteUrl"])

        desc = cutLength(
            removeTags(result["data"]["Character"]["description"]).replace(
                """, '"'))
        for title in result["data"]["Character"]["media"]["nodes"]:
            embed.add_field(name="Title of Source",
                            value='[{} ({})]({})'.format(
                                title["title"]["romaji"],
                                title["title"]["english"],
                                title["siteUrl"],
                                inline=False))
        embed.add_field(name="Description", value=desc, inline=False)
        embed.set_thumbnail(url=result["data"]["Character"]["image"]["large"])
        return embed
Ejemplo n.º 2
0
def mangaSearch(title):
    if title.isnumeric():
        query = SearchByID()
        variables = GetByID('manga', title)
    elif not title.isnumeric():
        query = SearchByTitle()
        variables = GetByTitle('manga', title)
    if variables:
        result = run_query(query, variables)
        if not result:
            return discord.Embed(
                description="There does not exist a manga with a title/ID of {}."
                .format(title))

        embed = discord.Embed(
            colour=discord.Colour.blue(),
            title=('{} ({}) {}'.format(
                result["data"]["Media"]["title"]["romaji"],
                result["data"]["Media"]["title"]["english"],
                result["data"]["Media"]["format"])),
            url=result["data"]["Media"]["siteUrl"],
            description=(removeTags(
                result["data"]["Media"]["description"])).replace(
                    """, '"'))

        embed.add_field(name="Status",
                        value=result["data"]["Media"]["status"].upper(),
                        inline=True)
        embed.add_field(name="Start Date",
                        value='{}/{}/{}'.format(
                            result["data"]["Media"]["startDate"]["day"],
                            result["data"]["Media"]["startDate"]["month"],
                            result["data"]["Media"]["startDate"]["year"]),
                        inline=True)
        embed.add_field(name="Number of Chapters",
                        value=replaceNone(result["data"]["Media"]["chapters"]),
                        inline=True)
        embed.add_field(name="Number of Volumes",
                        value=replaceNone(result["data"]["Media"]["volumes"]),
                        inline=True)
        embed.add_field(name="Favourites",
                        value=result["data"]["Media"]["favourites"],
                        inline=True)
        embed.add_field(name="Average Score",
                        value='{}'.format(replaceNone(
                            result["data"]["Media"]["averageScore"]),
                                          inline=True))
        embed.set_thumbnail(url=result["data"]["Media"]["coverImage"]["large"])
        return embed
Ejemplo n.º 3
0
def animeSearch(title):
    if title.isnumeric():
        query = SearchByID()
        variables = GetByID('anime', title)
    elif not title.isnumeric():
        query = SearchByTitle()
        variables = GetByTitle('anime', title)
    if variables:
        result = run_query(query, variables)
        if not result:
            return discord.Embed(
                description=
                "There does not exist an anime with a title/ID of {}.".format(
                    title))

        embed = discord.Embed(
            colour=discord.Colour.blue(),
            title=('{} ({}) {}'.format(
                result["data"]["Media"]["title"]["romaji"],
                result["data"]["Media"]["title"]["english"],
                result["data"]["Media"]["format"])),
            url=result["data"]["Media"]["siteUrl"],
            description=(removeTags(
                result["data"]["Media"]["description"])).replace(
                    """, '"'))
        embed.add_field(name="Status",
                        value=result["data"]["Media"]["status"].upper(),
                        inline=True)
        embed.add_field(name="Season",
                        value='{} {}'.format(
                            result["data"]["Media"]["season"],
                            result["data"]["Media"]["seasonYear"]),
                        inline=True)
        embed.add_field(name="Number of Episodes",
                        value=result["data"]["Media"]["episodes"],
                        inline=True)
        embed.add_field(name="Duration",
                        value='{} minutes/episode'.format(
                            result["data"]["Media"]["duration"], inline=True))
        embed.add_field(name="Favourites",
                        value=result["data"]["Media"]["favourites"],
                        inline=True)
        embed.add_field(name="Average Score",
                        value='{}%'.format(
                            result["data"]["Media"]["averageScore"],
                            inline=True))
        embed.set_thumbnail(url=result["data"]["Media"]["coverImage"]["large"])
        return embed
Ejemplo n.º 4
0
def staffSearch(staffName):
    query = searchStaff()
    variables = GetByStaff(staffName)
    if variables:
        result = run_query(query, variables)
        if not result:
            return discord.Embed(
                description="There does not exist a person with the name {}.".
                format(staffName))

        embed = discord.Embed(colour=discord.Colour.dark_orange(),
                              title=result["data"]["Staff"]["name"]["full"],
                              url=result["data"]["Staff"]["siteUrl"])

        characters = ""

        for char in result["data"]["Staff"]["characters"]["edges"]:
            characters += '[{}]({})'.format(char["node"]['name']['full'],
                                            char["node"]["siteUrl"]) + '\n\n'
        embed.add_field(name="Character List", value=characters)
        embed.set_thumbnail(url=result["data"]["Staff"]["image"]["large"])
        return embed
Ejemplo n.º 5
0
def studioSearch(studioName):
    query = searchStudio()
    variables = GetByStudio(studioName)
    if variables:
        result = run_query(query, variables)
        if not result:
            return discord.Embed(
                description="There does not exist a studio with a name of {}.".
                format(studioName))

        embed = discord.Embed(colour=discord.Colour.purple(),
                              title=result["data"]["Studio"]["name"],
                              url=result["data"]["Studio"]["siteUrl"])
        studioShows = ""

        for show in result["data"]["Studio"]["media"]["nodes"]:
            studioShows += '[{} ({})]({})'.format(
                (show["title"]["romaji"]),
                (show["title"]["english"]), show["siteUrl"]) + "\n\n"
        embed.add_field(name="Anime produced by {}".format(
            result["data"]["Studio"]["name"]),
                        value=studioShows)
        return embed
Ejemplo n.º 6
0
def generateUserInfo(userName):
    result = run_query(SearchUser(), GetUser(userName))
    return result