Пример #1
0
    async def remove_favourites(self, ctx: commands.Context, index=None):
        """ Remove something from favourites list """
        user_area = UserFavourites(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_favourites")
            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}rf 1`")
            command: commands.Command = self.bot.get_command("my_favourites")
            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 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.")
Пример #3
0
async def add_favourites(ctx, bot, name, url):
    user_tracker: UserFavourites = UserFavourites(user_id=ctx.author.id, database=bot.database)
    if (user_tracker.amount_of_items >= FALSE_PREMIUM_MAX_IN_STORE) and (ctx.has_voted(ctx.author.id) == 0):
        return {'content': "<:HimeMad:676087826827444227> Oh no! "
                           "You dont have enough space in your favourites "
                           "to add this, get more storage by voting here "
                           "https://top.gg/bot/656598065532239892/vote"
                }
    elif (user_tracker.amount_of_items >= TRUE_PREMIUM_MAX_IN_STORE[0]) and (ctx.has_voted(ctx.author.id) == 1):
        return {'content': f"<:HimeMad:676087826827444227> Oh no! "
                           f"You seem to have maxed out your favourites, you can get more by"
                           f" buying premium here to help support my development: {PREMIUM_URL}"
                }
    elif (user_tracker.amount_of_items >= TRUE_PREMIUM_MAX_IN_STORE[1]) and (ctx.has_voted(ctx.author.id) > 1):
        return {'content': f"<:HimeMad:676087826827444227> Oh wow! "
                           f"You've managed to add over {TRUE_PREMIUM_MAX_IN_STORE[1]} things to your favourites area! "
                           f"However, you'll need to either delete some to add more or contact my developer"
                           f" you can find him here: https://discord.gg/tJmEzWM"
                }
    else:
        try:
            user_tracker.add_content({'name': name, 'url': url})
            return {
                'content': f"<:HimeHappy:677852789074034691> Success!"
                           f" I've added {name} to your favourites!"
            }
        except (ValueError, TypeError, IndexError):
            return False
Пример #4
0
    async def my_favourites(self, ctx, option=None):
        """ Get your or someone else's favourites 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 = UserFavourites(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'} favourites,\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 = UserFavourites(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 = UserFavourites(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'} favourites,\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])