Beispiel #1
0
    def ani_character_page_1(title, data, char_media):
        url = data["siteUrl"]
        id = data["id"]
        desc = f"Details for character with id **{id}**:\n[Link to page]({url})"
        pic_url = data["image"]["large"]

        voice_actors, media = char_media
        va_str = ""
        for va in voice_actors:
            row = va + ", "
            if len(va_str) + len(row) > 1000:
                va_str += "[...]"
                break
            va_str += row

        name_full = data["name"]["full"]
        name_alternative = ", ".join(data["name"]["alternative"])
        about = data["description"]
        if about and len(about) > 1000:
            about = about[:1000] + "[...]"
        fields = [["Name", name_full], ["Nickname", name_alternative],
                  ["Favourites", data["favourites"]], ["About", about, False],
                  ["Voice actors", va_str[:-2], False]]
        emb = Embed().make_emb(title=title, desc=desc, fields=fields)
        emb.set_image(url=pic_url)
        emb.set_footer(text="1/2 - Powered by AniList API")
        return emb
Beispiel #2
0
    def ani_manga_page_1(title, data):
        url = data["siteUrl"]
        id = data["id"]
        desc = f"Details for manga with id **{id}**:\n[Link to page]({url})"
        pic_url = data["coverImage"]["large"]

        title_romaji = data["title"]["romaji"]
        title_english = data["title"]["english"]
        explicit = "Yes" if data["isAdult"] else "No"
        average_score = data["averageScore"]
        mean_score = data["meanScore"]
        rank = None
        for r in data["rankings"]:
            if r["type"] == "POPULAR" and r["allTime"]:
                rank = r["rank"]
                break
        fields = [["Title", f"{title_romaji},\n{title_english}"],
                  ["Type", data["format"]], ["Status", data["status"]],
                  ["Chapters", data["chapters"]], ["Volumes", data["volumes"]],
                  ["Explicit", explicit],
                  ["Score", f"{average_score} ({mean_score})"], ["Rank", rank]]
        emb = Embed().make_emb(title=title, desc=desc, fields=fields)
        emb.set_image(url=pic_url)
        emb.set_footer(text="1/5 - Powered by AniList API")
        return emb
Beispiel #3
0
 async def avatar(self, ctx, target: MemberConverter = None):
     """Info|Returns a user's avatar.|"""
     if not target:
         target = ctx.author
     avatartext = "**👉 |** ***{} - avatar.***".format(target.name)
     emb = Embed().make_emb("", avatartext)
     emb.set_image(url=target.avatar_url)
     await ctx.send(embed=emb)
Beispiel #4
0
    def ani_person_page_1(title, data):
        url = data["siteUrl"]
        id = data["id"]
        desc = f"Details for person with id **{id}**:\n[Link to page]({url})"
        pic_url = data["image"]["large"]

        name_full = data["name"]["full"]
        name_alternative = ", ".join(data["name"]["alternative"])
        about = data["description"]
        if about and len(about) > 1000:
            about = about[:1000] + "[...]"
        fields = [["Name", name_full], ["Nickname", name_alternative],
                  ["Favourites", data["favourites"]], ["About", about, False]]
        emb = Embed().make_emb(title=title, desc=desc, fields=fields)
        emb.set_image(url=pic_url)
        emb.set_footer(text="1/2 - Powered by AniList API")
        return emb
Beispiel #5
0
    def ani_user_page_1(title, desc, data):
        name = data["name"]
        about = data["about"]
        if about and len(about) > 1000:
            about = about[:1000] + "[...]"
        avatar = data["avatar"]["large"]
        banner = data["bannerImage"]
        score_format = data["mediaListOptions"]["scoreFormat"]

        anime = data["statistics"]["anime"]
        anime_str = "```Episodes watched: {}\nMean score: {}"
        anime_str = anime_str.format(anime["episodesWatched"],
                                     anime["meanScore"])
        for s in anime["statuses"]:
            st = s["status"]
            c = s["count"]
            anime_str += f"\n{st.title()}: {c}"
        anime_str += "\nTotal entries: {}```".format(anime["count"])
        manga = data["statistics"]["manga"]
        manga_str = "```Chapters read: {}\nMean score: {}"
        manga_str = manga_str.format(manga["chaptersRead"], manga["meanScore"])
        for s in manga["statuses"]:
            st = s["status"]
            c = s["count"]
            manga_str += f"\n{st.title()}: {c}"
        manga_str += "\nTotal entries: {}```".format(manga["count"])

        fields = [["Name", name], ["Score format", score_format],
                  ["About", about, False], ["Anime stats", anime_str, False],
                  ["Manga stats", manga_str]]
        emb = Embed().make_emb(title=title, desc=desc, fields=fields)
        emb.set_image(url=avatar)
        if banner:
            emb.set_thumbnail(url=banner)
        emb.set_footer(text="1/3 - Powered by AniList API")
        return emb
Beispiel #6
0
    async def send_key_drop(self, chan_obj, forced_drop=False):
        chan_id = chan_obj.id
        if forced_drop:
            if chan_id in self.active_key_drops:
                return await chan_obj.send(
                    "Key drop is already active... Please wait and try again, master."
                )
        self.active_key_drops.add(chan_id)
        pick = random.choice(os.listdir(self.key_drop_imgs_path))
        key_phrase = pick.split(".")[0]

        title = "A magical :key: has appeared!"
        desc = "Be the first to type the word **between the arrow heads** from the picture to get it!"
        perms = chan_obj.permissions_for(chan_obj.guild.me)
        if perms.embed_links:
            with open(f"{self.key_drop_imgs_path}/{pick}", 'rb') as g:
                embed = Embed().make_emb(title, desc)
                file = discord.File(g, filename="keydrop.png")
                embed.set_image(url="attachment://keydrop.png")
                first = await chan_obj.send(file=file, embed=embed)
        elif perms.attach_files:
            with open(f"{self.key_drop_imgs_path}/{pick}", 'rb') as g:
                prev_text = title + "\n" + desc
                first = await chan_obj.send(prev_text,
                                            file=discord.File(
                                                g, filename="keydrop.png"))
        else:
            if perms.send_messages:
                await chan_obj.send(
                    "I was going to drop a key for you, but you're not giving me perms to `attach files`! :confused:"
                )
            return self.active_key_drops.remove(chan_id)

        def check(msg):
            if msg.content.lower() == key_phrase:
                return True
            return False

        try:
            cf_mes = await self.bot.wait_for("message",
                                             check=check,
                                             timeout=25)
        except asyncio.TimeoutError:
            key_missed = "So sad, the word was `{}`... :disappointed:\nBe faster next time!".format(
                key_phrase)
            await chan_obj.send(key_missed)
        except Exception as e:
            print(e)
            return
        else:
            if cf_mes:
                user_id = cf_mes.author.id
                inv = await self.bot.funx.get_inventory(user_id)
                inv = self.bot.funx.inventory_add(inv, "keys")
                await self.bot.funx.save_inventory(user_id, inv)
                await chan_obj.send(
                    f"Nicely done, {cf_mes.author.mention}. You will get the key right away!"
                )
        finally:
            self.active_key_drops.remove(chan_id)
            await first.delete()