示例#1
0
    async def bday_list(self, ctx, mode: bool = None):
        """Lists all birthdays"""

        if mode == None:
            mode = await self.config.guild(ctx.guild).upcoming_first()

        bdays = await self.get_bdays(ctx.guild)

        if bdays != []:
            bdays = await self.sort_bdays(bdays, mode, ctx.guild)

            msg = ""
            previous_month = None

            async for bday in AsyncIter(bdays):
                month = datetime.datetime(year=1, month=int(bday[2]),
                                          day=1).strftime("%B")
                if month != previous_month:
                    msg += f"\n{bold(month)}\n"
                    previous_month = month

                try:
                    msg += f"{bday[1]}: {bold(str(bday[0]))} - {bold(str(bday[3]))} years\n"
                except IndexError:
                    msg += f"{bday[1]}: {bold(str(bday[0]))}\n"

            pages = list(pagify(msg, delims=["\n\n"], page_length=1000))

            pages = menus.MenuPages(source=MenuSource(pages, "Birthday list"),
                                    clear_reactions_after=True)
            await pages.start(ctx)

        else:
            await ctx.send("No birthdays set on this server.")
示例#2
0
 async def last(self, ctx: Context):
     """
     Displays the most recently aired anime episodes.
     """
     async with ctx.channel.typing():
         try:
             data = await self.anilist.schedule(
                 page=1, perPage=15, notYetAired=False, sort="TIME_DESC"
             )
         except Exception as e:
             log.exception(e)
             embed = discord.Embed(
                 title=f"An error occurred while searching for the most recently aired episodes. Try again.",
                 color=discord.Color.random(),
             )
             return await ctx.channel.send(embed=embed)
         if data is not None and len(data) > 0:
             embeds = []
             for page, anime in enumerate(data):
                 try:
                     embed = await self.get_last_embed(anime, page + 1, len(data))
                     if (
                         is_adult(anime.get("media"))
                         and not ctx.channel.is_nsfw()
                     ):
                         embed = discord.Embed(
                             title="Error",
                             color=discord.Color.random(),
                             description=f"Adult content. No NSFW channel.",
                         )
                         embed.set_footer(
                             text=f"Provided by https://anilist.co/ • Page {page + 1}/{len(data)}"
                         )
                 except Exception as e:
                     log.exception(e)
                     embed = discord.Embed(
                         title="Error",
                         color=discord.Color.random(),
                         description=f"An error occurred while loading the embed for the recently aired episode.",
                     )
                     embed.set_footer(
                         text=f"Provided by https://anilist.co/ • Page {page + 1}/{len(data)}"
                     )
                 embeds.append(embed)
             menu = menus.MenuPages(
                 source=EmbedListMenu(embeds),
                 clear_reactions_after=True,
                 timeout=30,
             )
             await menu.start(ctx)
         else:
             embed = discord.Embed(
                 title=f"The most recently aired episodes could not be found.",
                 color=discord.Color.random(),
             )
             await ctx.channel.send(embed=embed)
示例#3
0
 async def themes(self, ctx: Context, *, anime: str):
     """
     Searches for the openings and endings of the given anime and displays them.
     """
     async with ctx.channel.typing():
         data = await self.animethemes.search(anime, 5, ["anime"])
         if data.get("search").get("anime"):
             embeds = []
             for page, entry in enumerate(data.get("search").get("anime")):
                 try:
                     embed = await self.get_themes_embed(
                         entry, page + 1, len(data.get("search").get("anime"))
                     )
                     if (
                         is_adult(entry.get("themes")[0]["entries"][0])
                         and not ctx.channel.is_nsfw()
                     ):
                         embed = discord.Embed(
                             title="Error",
                             color=discord.Color.random(),
                             description=f"Adult content. No NSFW channel.",
                         )
                         embed.set_footer(
                             text=f"Provided by https://animethemes.moe/ • Page {page + 1}/"
                             f'{len(data.get("anime"))}'
                         )
                 except Exception as e:
                     log.exception(e)
                     embed = discord.Embed(
                         title="Error",
                         color=discord.Color.random(),
                         description=f"An error occurred while loading the embed for the anime.",
                     )
                     embed.set_footer(
                         text=f'Provided by https://animethemes.moe/ • Page {page + 1}/{len(data.get("anime"))}'
                     )
                 embeds.append(embed)
             menu = menus.MenuPages(
                 source=EmbedListMenu(embeds), clear_reactions_after=True, timeout=30
             )
             await menu.start(ctx)
         else:
             embed = discord.Embed(
                 title=f"No themes for the anime `{anime}` found.", color=discord.Color.random()
             )
             await ctx.channel.send(embed=embed)
示例#4
0
 async def studio_(self, ctx: Context, *, name: str):
     """
     Searches for a studio with the given name and displays information about the search results such as the studio
     productions!
     """
     async with ctx.channel.typing():
         embeds = await self.anilist_search(ctx, name, AniListSearchType.STUDIO)
         if embeds:
             menu = menus.MenuPages(
                 source=EmbedListMenu(embeds),
                 clear_reactions_after=True,
                 timeout=30,
             )
             await menu.start(ctx)
         else:
             embed = discord.Embed(
                 title=f"The studio `{name}` could not be found.",
                 color=discord.Color.random(),
             )
             await ctx.channel.send(embed=embed)
示例#5
0
 async def character(self, ctx: Context, *, name: str):
     """
     Searches for a character with the given name and displays information about the search results such as
     description, synonyms, and appearances!
     """
     async with ctx.channel.typing():
         embeds = await self.anilist_search(ctx, name, AniListSearchType.CHARACTER)
         if embeds:
             menu = menus.MenuPages(
                 source=EmbedListMenu(embeds),
                 clear_reactions_after=True,
                 timeout=30,
             )
             await menu.start(ctx)
         else:
             embed = discord.Embed(
                 title=f"The character `{name}` could not be found.",
                 color=discord.Color.random(),
             )
             await ctx.channel.send(embed=embed)
示例#6
0
 async def manga(self, ctx: Context, *, title: str):
     """
     Searches for a manga with the given title and displays information about the search results such as type,
     status, chapters, description, and more!
     """
     async with ctx.channel.typing():
         embeds = await self.anilist_search(ctx, title, AniListSearchType.MANGA)
         if embeds:
             menu = menus.MenuPages(
                 source=EmbedListMenu(embeds),
                 clear_reactions_after=True,
                 timeout=30,
             )
             await menu.start(ctx)
         else:
             embed = discord.Embed(
                 title=f"The manga `{title}` could not be found.",
                 color=discord.Color.random(),
             )
             await ctx.channel.send(embed=embed)
示例#7
0
 async def crunchynews(self, ctx: Context):
     """
     Displays the latest anime news from Crunchyroll.
     """
     async with ctx.channel.typing():
         try:
             data = await self.crunchyroll.news(count=15)
         except Exception as e:
             log.exception(e)
             embed = discord.Embed(
                 title=f"An error occurred while searching for the Crunchyroll news. Try again.",
                 color=discord.Color.random(),
             )
             return await ctx.channel.send(embed=embed)
         if data is not None and len(data) > 0:
             embeds = []
             for page, news in enumerate(data):
                 try:
                     embed = await self.get_crunchynews_embed(news, page + 1, len(data))
                 except Exception as e:
                     log.exception(e)
                     embed = discord.Embed(
                         title="Error",
                         color=discord.Color.random(),
                         description=f"An error occurred while loading the embed for the Crunchyroll news.",
                     )
                     embed.set_footer(
                         text=f"Provided by https://www.crunchyroll.com/ • Page {page + 1}/{len(data)}"
                     )
                 embeds.append(embed)
             menu = menus.MenuPages(
                 source=EmbedListMenu(embeds), clear_reactions_after=True, timeout=30
             )
             await menu.start(ctx)
         else:
             embed = discord.Embed(
                 title=f"The Crunchyroll news could not be found.",
                 color=discord.Color.random(),
             )
             await ctx.channel.send(embed=embed)