Example #1
0
async def pokemon_route(ctx:tanjun.abc.SlashContext, pokemon:str, version:str):

    try:
        possibilities = ["red","blue","diamond","pearl","platinum","yellow","gold","silver","crystal","firered","leafgreen","heartgold","soulsilver","ruby","sapphire","emerald","x","y","omega-ruby","alpha-sapphire","black","white"]

        matches = difflib.get_close_matches(
            version.lower(), possibilities, n=1, cutoff=0.3)

        pokemondata = (requests.get("https://pokeapi.co/api/v2/pokemon/{}/encounters".format(pokemon.lower()))).json()

        vlist = []
        dlist = []
        

        for x in pokemondata:
            version = x["version_details"][0]
            if version["version"]["name"] == matches[0]:
                vlist.append(x)
            else:
                if version["version"]["name"]:
                    dlist.append(version["version"]["name"])
                    dlist = list(set(dlist))

        if len(vlist) > 0:
            embed = hikari.Embed(
                title = pokemon.title() + " Routes " "- Version: " + matches[0].title(),
                color = hikari.Color(0xee1515)
                )

            for y in vlist:
                version = y["version_details"][0]
                name = y["location_area"]["name"].replace("-", " ")
                embed.add_field(name=name.title(), value="Encounter Potential: " + str(version["max_chance"]) + "%", inline=False)

            await ctx.respond(embed)
            
        elif len(vlist) <= 1 and dlist == []:
            await ctx.respond("This pokemon cannot be found in wild grass.")
            
        elif vlist == [] and len(dlist) > 0:
            embed = hikari.Embed(
                title = pokemon.title() + " can be found in these versions!",
                color = hikari.Color(0xee1515)
                )
            for x in dlist:
                embed.add_field(name=x.title(), value="\u200b", inline=True)

            await ctx.respond(embed)   
            
    except JSONDecodeError:
        await ctx.respond("Make sure the pokemon's name is typed correctly!")
Example #2
0
async def mtg_rulings(ctx:tanjun.abc.SlashContext, card:str):


    try:
        mtgdata = (requests.get("https://api.magicthegathering.io/v1/cards?name={}&pageSize=1&contains=imageUrl".format(card.lower()))).json()

        card = mtgdata.get("cards")[0]

        rulings = card["rulings"]        

        embed = hikari.Embed(
            title = "Rulings.",
            color = hikari.Color(0xFF0000)
        )

        embed.set_thumbnail(card["imageUrl"])

        for x in rulings:
            embed.add_field(name="Date: {}".format(x["date"]), value= x["text"], inline=False)

        await ctx.respond(embed)
    
    except IndexError:
        await ctx.respond("Please double check the spelling of the card.")

    except KeyError:
        await ctx.respond("This card does not have any rulings.")
Example #3
0
async def count(ctx: tanjun.abc.SlashContext, game: str) -> None:
    results = await SteamSearch(game)

    appID = results[0]
    name = results[1]

    gsdata = (requests.get(
        "https://store.steampowered.com/api/appdetails/?appids={}&l=english".
        format(appID))).json()

    codata = (requests.get(
        "https://api.steampowered.com/ISteamUserStats/GetNumberOfCurrentPlayers/v1/?appid={}"
        .format(appID))).json()

    check = codata["response"]

    if check.get("player_count") not in check.values():
        await ctx.respond("This game currently does not have players online.")

    else:
        player_count = codata["response"]["player_count"]
        appdetails = gsdata.get("{}".format(appID)).get("data")

        embed = hikari.Embed(title=name,
                             description="There are currently " +
                             "`{}`".format(player_count) + " playing.",
                             color=hikari.Color(0x808080))

        embed.set_thumbnail(appdetails["header_image"])

        await ctx.respond(embed)
Example #4
0
async def specials(ctx: tanjun.abc.SlashContext) -> None:

    locale.setlocale(locale.LC_ALL, "en_US.UTF-8")

    sdata = (requests.get(
        "http://store.steampowered.com/api/featuredcategories/&l=english")
             ).json()

    specials = sdata["specials"]["items"]

    special1 = specials[0]
    special2 = specials[1]
    special3 = specials[2]
    special4 = specials[3]
    special5 = specials[4]

    embed = hikari.Embed(
        title="Specials",
        url="https://store.steampowered.com/search/?specials=1",
        color=hikari.Color(0xE6E6FA))

    embed.add_field(name=special1["name"],
                    value="Price: " +
                    locale.currency(float(special1["final_price"]) / 100.0) +
                    "\nDiscount Ends: " + datetime.datetime.fromtimestamp(
                        special1["discount_expiration"]).strftime('%m/%d/%Y'),
                    inline=False)

    embed.add_field(name=special2["name"],
                    value="Price: " +
                    locale.currency(float(special2["final_price"]) / 100.0) +
                    "\nDiscount Ends: " + datetime.datetime.fromtimestamp(
                        special2["discount_expiration"]).strftime('%m/%d/%Y'),
                    inline=False)

    embed.add_field(name=special3["name"],
                    value="Price: " +
                    locale.currency(float(special3["final_price"]) / 100.0) +
                    "\nDiscount Ends: " + datetime.datetime.fromtimestamp(
                        special3["discount_expiration"]).strftime('%m/%d/%Y'),
                    inline=False)

    embed.add_field(name=special4["name"],
                    value="Price: " +
                    locale.currency(float(special4["final_price"]) / 100.0) +
                    "\nDiscount Ends: " + datetime.datetime.fromtimestamp(
                        special4["discount_expiration"]).strftime('%m/%d/%Y'),
                    inline=False)

    embed.add_field(name=special5["name"],
                    value="Price: " +
                    locale.currency(float(special5["final_price"]) / 100.0) +
                    "\nDiscount Ends: " + datetime.datetime.fromtimestamp(
                        special5["discount_expiration"]).strftime('%m/%d/%Y'),
                    inline=False)

    await ctx.respond(embed)
Example #5
0
async def game_updates(ctx: tanjun.abc.SlashContext, game: str) -> None:

    results = await SteamSearch(game)

    appID = results[0]

    updata = (requests.get(
        "https://api.steampowered.com/ISteamNews/GetNewsForApp/v2/?appid={}".
        format(appID))).json()

    cleanr = re.compile(f'<.*?>|{{.*?}}|\[img\].+\[/img\]|\[.*?\]')

    def cleanhtml(raw_html):
        cleantext = re.sub(cleanr, '', raw_html)
        return cleantext

    items = updata["appnews"]["newsitems"]

    item = [x for x in items if x["feedlabel"] == "Community Announcements"]

    contents = cleanhtml(item[0]["contents"])

    # Tokenizes sentence to limit the amt of sentences displayed.

    scontents = sent_tokenize(contents)
    contents = " ".join([str(item) for item in scontents[:5]])

    url = item[0]["url"]
    url = url.replace(" ", "")

    embed = hikari.Embed(title=item[0]["title"],
                         url=url,
                         description=contents,
                         color=hikari.Color(0x454B1B))

    date_time = item[0]["date"]
    date_time = datetime.datetime.fromtimestamp(date_time).strftime('%m/%d/%Y')

    embed.add_field(name="Date: ", value=date_time, inline=True)

    if item[0]["author"] != "":

        embed.add_field(name="Author: ", value=item[0]["author"], inline=True)

    else:
        pass

    embed.set_footer(text=item[0]["feedlabel"])

    await ctx.respond(embed=embed)
Example #6
0
async def mtg_list(ctx:tanjun.abc.SlashContext, card:str):

    try:

        mtgdata = (requests.get("https://api.magicthegathering.io/v1/cards?name={}&pageSize=7&contains=imageUrl".format(card.lower()))).json()

        cards = mtgdata.get("cards")
            

        embed = hikari.Embed(
            title = "Cards",
            color = hikari.Color(0x228b22)
        )


        for x in cards:
            embed.add_field(name=x["name"], value="Set: " + x["setName"], inline=False)

        await ctx.respond(embed)
    except IndexError:
        await ctx.respond("Please double check the spelling of the card.")
Example #7
0
async def pokemon_nature(ctx:tanjun.abc.SlashContext, nature:str):
    
    possibilities = ["adamant","bashful","bold","brave","calm","careful","docile","gentle","hardy","hasty","impish","jolly","lax","lonely","mild","modest","naive","naughty","quiet","quirky","rash","relaxed","sassy","serious","timid"]
    
    matches = difflib.get_close_matches(
        nature.lower(), possibilities, n=1, cutoff=0.3)
    
    pokemondata = (requests.get("https://pokeapi.co/api/v2/nature/{}/".format(matches[0].lower()))).json()
    move_preference = pokemondata['move_battle_style_preferences']

    embed= hikari.Embed(
        title = pokemondata["name"].title(),
        color = hikari.Color(0xffcb05)
    )

    embed.add_field(name="Decreased Stat", value = pokemondata['decreased_stat']['name'].title(), inline=True)
    embed.add_field(name="Increased Stat", value = pokemondata['increased_stat']['name'].title(), inline=True)
    embed.add_field(name="Likes Flavor", value = pokemondata['likes_flavor']['name'].title(), inline=True)
    embed.add_field(name="Hates Flavor", value = pokemondata['hates_flavor']['name'].title(), inline=True)

    for x in move_preference:
        embed.add_field(name=x['move_battle_style']['name'].title(), value = "High HP Preference: " + str(x['high_hp_preference']) + "%" + "\nLow HP Preference: " + str(x['low_hp_preference']) + "%", inline=False)

    await ctx.respond(embed)
Example #8
0
    def purple(): return hikari.Color(0x9b59b6)

    @staticmethod
Example #9
0
    def dark_blue(): return hikari.Color(0x206694)

    @staticmethod
Example #10
0
    def blue(): return hikari.Color(0x3498db)

    @staticmethod
Example #11
0
    def og_blurple(): return hikari.Color(0x7289da)

    @staticmethod
Example #12
0
    def lighter_gray(): return hikari.Color(0x95a5a6)

    @staticmethod
Example #13
0
    def light_gray(): return hikari.Color(0x979c9f)

    @staticmethod
Example #14
0
    def teal(): return hikari.Color(0x1abc9c)

    @staticmethod
Example #15
0
    def yellow(): return hikari.Color(0xFEE75C)

def get_emote(discord_text: str) -> str:
Example #16
0
    def fuchsia(): return hikari.Color(0xEB459E)

    @staticmethod
Example #17
0
    def dark_theme(): return hikari.Color(0x36393F)

    @staticmethod
Example #18
0
    def greyple(): return hikari.Color(0x5865F2)

    @staticmethod
Example #19
0
    def blurple(): return hikari.Color(0x5865F2)

    @staticmethod
Example #20
0
    def dark_purple(): return hikari.Color(0x71368a)

    @staticmethod
Example #21
0
    def magenta(): return hikari.Color(0xe91e63)

    @staticmethod
Example #22
0
    def dark_teal(): return hikari.Color(0x11806a)

    @staticmethod
Example #23
0
async def _game_embed(ctx: tanjun.abc.Context, appID) -> None:

    # API request to then get game details using appID.
    gsdata = (requests.get(
        "https://store.steampowered.com/api/appdetails/?appids={}&l=english".
        format(appID))).json()

    # Remove html content from description and notice.
    cleanr = re.compile('<.*?>')

    def cleanhtml(raw_html):
        cleantext = re.sub(cleanr, '', raw_html)
        return cleantext

    # API request to get reviews for games.

    rdata = (requests.get(
        "https://store.steampowered.com/appreviews/{}?json=1".format(appID))
             ).json()

    # Accessing data dictionary and assigned them values.

    appdetails = gsdata.get("{}".format(appID)).get("data")
    description = appdetails.get("short_description")

    embed = hikari.Embed(
        title=appdetails["name"],
        url="https://store.steampowered.com/app/{}/".format(appID),
        description=cleanhtml(description),
        color=hikari.Color(0x00FFFF))
    embed.set_image(appdetails["header_image"])
    # If statement to check if game has a legal notice or not.

    if appdetails.get("legal_notice") not in appdetails.values(
    ) or appdetails.get("legal_notice") == None:
        embed.set_footer(text="")
    else:
        notice = appdetails["legal_notice"]
        snotice = sent_tokenize(notice)
        notice = " ".join([str(item) for item in snotice[:1]])
        embed.set_footer(text=cleanhtml(notice))

    # Adding multiple devs to developer field.

    dev = ", ".join([str(item) for item in appdetails.get("developers")])
    embed.add_field(name="Developers: ", value=dev, inline=True)

    # Price checks for games.

    price = appdetails.get("price_overview")

    if appdetails["is_free"] == True:
        embed.add_field(name="Price: ", value="Free", inline=True)

    elif appdetails["release_date"]["coming_soon"] == True and price is None:
        embed.add_field(name="Price: ", value="Coming Soon.", inline=True)

    elif price.get("initial_formatted") != "":
        embed.add_field(name="Price: ",
                        value="~~{}~~".format(price.get("initial_formatted")) +
                        " " + "**{}**".format(price.get("final_formatted")),
                        inline=True)

    else:
        embed.add_field(name="Price: ",
                        value=price["final_formatted"],
                        inline=True)

    review = rdata["query_summary"]["review_score_desc"]

    embed.add_field(name="Review:", value=review, inline=True)

    try:
        await ctx.edit_last_response(content="", embed=embed)

    except LookupError:
        await ctx.respond(embed)
Example #24
0
    def dark_red(): return hikari.Color(0x992d22)

    @staticmethod
Example #25
0
    def dark_gray(): return hikari.Color(0x607d8b)

    @staticmethod
Example #26
0
    def dark_green(): return hikari.Color(0x1f8b4c)

    @staticmethod
Example #27
0
    def brand_green(): return hikari.Color(0x57F287)

    @staticmethod
Example #28
0
    def darker_gray(): return hikari.Color(0x546e7a)

    @staticmethod
Example #29
0
    def green(): return hikari.Color(0x2ecc71)

    @staticmethod
Example #30
0
    def red(): return hikari.Color(0xe74c3c)

    @staticmethod