Пример #1
0
    async def remove_recommended(self, ctx, index=None):
        """ Remove something from recommended list """

        user_area = UserRecommended(user_id=ctx.author.id,
                                    database=self.bot.database)
        if index is None:
            await ctx.send(
                "Oops! You haven't given me a number that matches to your list, check your list here:"
            )
            command: commands.Command = self.bot.get_command("my_recommended")
            return await command.invoke(ctx)

        try:
            index = int(index)
        except ValueError:
            await ctx.send(
                "Oops! You appear to have given me something that is not a number, to remove "
                "a item specify the number that is listed next to the item.\n"
                f"Example command: `{ctx.prefix}rr 1`")
            command: commands.Command = self.bot.get_command("my_recommended")
            return await command.invoke(ctx)

        if index < 0:
            return await ctx.send(
                "<:cheeky:717784139226546297> You cant remove a negative number silly!"
            )
        if index - 1 in range(0, user_area.amount_of_items):
            deleted = user_area.remove_content(index - 1)
            return await ctx.send(
                f"{random.choice(RANDOM_EMOJIS)} All done! Ive removed {deleted['name']}"
            )
Пример #2
0
    async def recommend(self,
                        ctx,
                        user: discord.Member = None,
                        *,
                        argument: str = None):
        """ Add Anime to to someone's recommended list """
        if user is None:
            return await ctx.send(
                f"<:HimeMad:676087826827444227> Oops! "
                f"You didnt mention the person you wanted to recommend an Anime to."
            )

        user_area = UserRecommended(user_id=user.id,
                                    database=self.bot.database)
        if not user_area.is_public:
            return await ctx.send(
                f"<:HimeMad:676087826827444227> Oops! "
                f"The user you mentioned has their recommended list set to private."
            )

        if argument is None:
            return await ctx.send(
                f"<:HimeMad:676087826827444227> Oh no! "
                f"You didnt give me anything to add to {user.display_name}'s recommended list."
                f" Do `{ctx.prefix}help recommended` for more info.")

        items = argument.split("url=", 1)
        if len(items) > 1:
            name, url = items
            if name == '':
                split = url.split(" ", 1)
                if len(split
                       ) > 1:  # Reverse the order in case someone is a moron
                    name, url = split[1], split[0]
                else:
                    return await ctx.send(
                        f"<:HimeMad:676087826827444227> Oops! "
                        f"You didnt give a title but gave a url, "
                        f"please do `{ctx.prefix}help addanime` for more info."
                    )
            if not url.startswith("http"):
                url = None
        else:
            name, url = items[0], None
        if name.endswith(" "):
            name = name[:len(name) - 1]
        try:
            user_area.add_content({'name': name, 'url': url})
            return await ctx.send(
                f"<:HimeHappy:677852789074034691> Success!"
                f""" I've added "{name}" to {user.name}'s recommended list.""")
        except Exception as e:
            return await ctx.send(
                f"Oh no! A error jumped out and scared me: {e}")
Пример #3
0
 async def firewall(self, ctx, command_: str):
     """ Toggle public/private system """
     if command_ == "recommended":
         user_area = UserRecommended(user_id=ctx.author.id,
                                     database=self.bot.database)
         mode = user_area.toggle_public()
         return await ctx.send(
             f"<:HimeHappy:677852789074034691> Your recommended"
             f" list is now {'**public**' if mode else '**private**'}")
     elif command_ == "watchlist":
         user_area = UserWatchlist(user_id=ctx.author.id,
                                   database=self.bot.database)
         mode = user_area.toggle_public()
         return await ctx.send(
             f"<:HimeHappy:677852789074034691> Your watchlist"
             f" list is now {'**public**' if mode else '**private**'}")
     elif command_ == "favourites":
         user_area = UserFavourites(user_id=ctx.author.id,
                                    database=self.bot.database)
         mode = user_area.toggle_public()
         return await ctx.send(
             f"<:HimeHappy:677852789074034691> Your favourites"
             f" list is now {'**public**' if mode else '**private**'}")
     else:
         return await ctx.send(
             f"Sorry, that's not a valid command to firewall.")
Пример #4
0
    async def my_recommended(self, ctx, option=None):
        """ Get your or someone else's recommended list
            args:
                option - This can be any string but can only be valid as a bool
                         or a member to be used by the member converter but not Both.
                         In this case Member will always be picked over the cycle option.
        """

        cycle = False
        member = None

        if option is not None:
            cycle = option.lower() == "--cycle" or option.lower() == "-c"

            try:
                member = await convert_member(ctx, option)
            except commands.BadArgument:
                member = None

        if cycle:
            user_area = UserRecommended(user_id=ctx.author.id,
                                        database=self.bot.database)
            if user_area.amount_of_items <= 0:
                embed = discord.Embed(color=self.bot.colour) \
                    .set_footer(text="Hint: Vote for Crunchy on top.gg to get more perks!")
                embed.description = f"Oops! {'You' if member is None else 'They'} dont " \
                                    f"have anything in {'your' if member is None else 'their'} recommended,\n" \
                                    f" lets get filling it!"
                embed.set_thumbnail(url=random.choice(SAD_URL))
                embed.set_author(name=f"{ctx.author.name}'s {user_area.type}",
                                 icon_url=ctx.author.avatar_url)
                return await ctx.send(embed=embed)
            return await self.cycle_items(ctx, user_area)

        if member is not None:
            user_ = member
            user_area = UserRecommended(user_id=member.id,
                                        database=self.bot.database)
            if not user_area.is_public:
                return await ctx.send(
                    "Oops! This user has their recommended firewalled (Private)."
                )
        else:
            user_ = ctx.author
            user_area = UserRecommended(user_id=ctx.author.id,
                                        database=self.bot.database)
        if user_area.amount_of_items <= 0:
            embed = discord.Embed(color=self.bot.colour) \
                .set_footer(text="Hint: Vote for Crunchy on top.gg to get more perks!")
            embed.description = f"Oops! {'You' if member is None else 'They'} dont " \
                                f"have anything in {'your' if member is None else 'their'} recommended,\n" \
                                f" lets get filling it!"
            embed.set_thumbnail(url=random.choice(SAD_URL))
            embed.set_author(name=f"{user_.name}'s {user_area.type}",
                             icon_url=user_.avatar_url)
            return await ctx.send(embed=embed)
        else:
            embeds = await self.generate_embeds(user=user_, area=user_area)
            if len(embeds) > 1:
                pager = Paginator(embed_list=embeds,
                                  bot=self.bot,
                                  message=ctx.message,
                                  colour=self.bot.colour)
                return self.bot.loop.create_task(pager.start())
            return await ctx.send(embed=embeds[0])