コード例 #1
0
ファイル: games.py プロジェクト: Kile/Killua
    async def rps(self, ctx, member: discord.Member, points: int = None):
        """Play Rock Paper Scissors with your friends! You can play investing Jenny or just for fun."""

        if member.id == ctx.author.id:
            return await ctx.send('Baka! You can\'t play against yourself')

        if not member.bot:
            opponent = User(member.id)
        elif member.bot and member != ctx.me:
            return await ctx.send(
                'Beep-boop, if you wanna play against a bot, play against me!')

        p2 = opponent.jenny if member != ctx.me else False

        user = User(ctx.author.id)

        p1 = user.jenny

        if points:
            if points <= 0 or points > 100:
                return await ctx.send(f'You can only play using 1-100 Jenny')

            if p1 < points:
                return await ctx.send(
                    f'You do not have enough Jenny for that. Your current balance is `{p1}`'
                )
            if not p2 is False and p2 < points:
                return await ctx.send(
                    f'Your opponent does not have enough Jenny for that. Their current balance is `{p2}`'
                )

        game = Rps(ctx, points, member)
        await game.start()
コード例 #2
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self) -> None:
        author = User(self.ctx.author.id)
        author.remove_card(self.id)

        users = []
        stolen_cards = []

        async for message in self.ctx.channel.history(limit=20):
            if message.author not in users and message.author.bot is False and message.author != self.ctx.author:
                users.append(message.author)

        for user in users:
            try:
                self._permission_check(self.ctx, user)
                u = User(user.id)
                self._has_cards_check(u.all_cards)
                target = random.choice([x for x in u.all_cards if x[0] != 0])
                await self._attack_defense_check(self.ctx, u, target)
                r = u.remove_card(target[0], target[1]["fake"])
                stolen_cards.append(r)
            except Exception as e:
                continue

        if len(stolen_cards) > 0:
            author.add_multi(stolen_cards)
            await self.ctx.send(f'Success! Stole the card{"s" if len(stolen_cards) > 1 else ""} {", ".join([str(x[0]) for x in stolen_cards])} from {len(stolen_cards)} user{"s" if len(users) > 1 else ""}!')
        else:
            await self.ctx.send('All targetted users were able to defend themselves!')
コード例 #3
0
ファイル: games.py プロジェクト: Kile/Killua
 async def _eval_outcome(self, winlose: int, choice1, choice2,
                         player1: discord.Member,
                         player2: discord.Member) -> discord.Message:
     """Evaluates the outcome, informs the players and handles the points """
     p1 = User(player1.id)
     p2 = User(player2.id)
     if winlose == -1:
         if self.points:
             p1.add_jenny(self.points)
             if player2 != self.ctx.me:
                 p2.remove_jenny(self.points)
             return await self.ctx.send(
                 f'{self.emotes[choice1]} > {self.emotes[choice2]}: {player1.mention} won against {player2.mention} winning {self.points} Jenny which adds to a total of {p1.jenny}'
             )
         else:
             return await self.ctx.send(
                 f'{self.emotes[choice1]} > {self.emotes[choice2]}: {player1.mention} won against {player2.mention}'
             )
     elif winlose == 0:
         return await self.ctx.send(
             f'{self.emotes[choice1]} = {self.emotes[choice2]}: {player1.mention} tied against {player2.mention}'
         )
     elif winlose == 1:
         if self.points:
             p1.remove_jenny(self.points)
             if player2 != self.ctx.me:
                 p2.add_jenny(self.points)
             return await self.ctx.send(
                 f'{self.emotes[choice1]} < {self.emotes[choice2]}: {player1.mention} lost against {player2.mention} losing {self.points} Jenny which leaves them a total of {p1.jenny}'
             )
         else:
             return await self.ctx.send(
                 f'{self.emotes[choice1]} < {self.emotes[choice2]}: {player1.mention} lost against {player2.mention}'
             )
コード例 #4
0
    async def _validate(
            self, ctx: commands.Context, other: discord.Member
    ) -> Union[discord.Message, Tuple[User, User]]:
        """Validates if someone is a bot or the author and returns a tuple of users if correct, else a message"""
        if other == ctx.author:
            return await ctx.send('You can\'t give yourself anything!')
        if other.bot:
            return await ctx.send('🤖')

        return User(ctx.author.id), User(other.id)
コード例 #5
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member) -> None:
        author = User(self.ctx.author.id)
        other = User(member.id)
        author.remove_card(self.id)

        self._has_cards_check(other.rs_cards, f" in their restricted slots!", uses_up=True)
        card = random.choice([x for x in other.rs_cards if x[0] != 0])
        self._is_maxed_check(card[0])

        author.add_card(card[0], card[1]["fake"], True)
        await self.ctx.send(f'Successfully added another copy of card No. {card[0]} to your book! This card is {"not" if card[1]["fake"] is False else ""} a fake!')
コード例 #6
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member) -> None:
        self._permission_check(self.ctx, member)

        other = User(member.id)
        author = User(self.ctx.author.id)

        self._has_cards_check(other.rs_cards, " in their restricted slots")

        target_card = random.choice([x for x in other.rs_cards if not x[0] in INDESTRUCTABLE and x[0] != 0])
        author.remove_card(self.id)
        await self._attack_defense_check(self.ctx, other, target_card)
        other.remove_card(target_card[0], remove_fake=target_card[1]["fake"], restricted_slot=True, clone=target_card[1]["clone"])
        await self.ctx.send(f'Success, you destroyed card No. {target_card[0]}!')
コード例 #7
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member) -> None:
        author = User(self.ctx.author.id)
        other = User(member.id)

        self._has_met_check(self.ctx.bot.command_prefix(self.ctx.bot, self.ctx.message)[2], author, member)
        
        self._permission_check(self.ctx, member)    
        author.remove_card(self.id)
        await self._view_defense_check(self.ctx, other)

        async def make_embed(page, embed, pages):
            return await Book(self.ctx.bot.session).create(member, page)

        await Paginator(self.ctx, max_pages=6, func=make_embed, has_file=True).start() 
コード例 #8
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member) -> None:
        author = User(self.ctx.author.id)
        other = User(member.id)

        self._has_met_check(self.ctx.bot.command_prefix(self.ctx.bot, self.ctx.message)[2], author, member)

        author.remove_card(self.id)

        self._has_cards_check(other.all_cards)

        async def make_embed(page, embed, pages):
            return await Book(self.ctx.bot.session).create(member, page)

        return await Paginator(self.ctx, max_pages=6+math.ceil(len(other.fs_cards)/18), func=make_embed, has_file=True).start()
コード例 #9
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member):
        self._permission_check(self.ctx, member)

        author = User(self.ctx.author.id)
        other = User(member.id)

        self._has_cards_check(other.rs_cards, " in their restricted slots")

        target_card = random.choice([x[0] for x in other.rs_cards if x[0] != 0])
        author.remove_card(self.id)
        await self._attack_defense_check(self.ctx, other, target_card)

        removed_card = other.remove_card(target_card, restricted_slot=True)
        author.add_card(target_card, removed_card[1]["fake"])
        await self.ctx.send(f'Successfully stole card number `{target_card}` from `{member}`!')
コード例 #10
0
    async def card(self, ctx, item: int):
        """Buy a card from the shop with this command"""

        shop_data = shop.find_one({'_id': 'daily_offers'})
        shop_items = shop_data['offers']
        user = User(ctx.author.id)

        try:
            card = Card(item)
        except CardNotFound:
            return await ctx.send(
                f'This card is not for sale at the moment! Find what cards are in the shop with `{self.client.command_prefix(self.client, ctx.message)[2]}shop`',
                allowed_mentions=discord.AllowedMentions.none())

        if not item in shop_items:
            return await ctx.send(
                f'This card is not for sale at the moment! Find what cards are in the shop with `{self.client.command_prefix(self.client, ctx.message)[2]}shop`',
                allowed_mentions=discord.AllowedMentions.none())

        if not shop_data['reduced'] is None:
            if shop_items.index(
                    card.id) == shop_data['reduced']['reduced_item']:
                price = int(PRICES[card.rank] -
                            int(PRICES[card.rank] *
                                (shop_data['reduced']['reduced_by'] / 100)))
            else:
                price = PRICES[card.rank]
        else:
            price = PRICES[card.rank]

        if len(card.owners) >= (card.limit * ALLOWED_AMOUNT_MULTIPLE):
            return await ctx.send(
                'Unfortunately the global maximal limit of this card is reached! Someone needs to sell their card for you to buy one or trade/give it to you'
            )

        if len(user.fs_cards) >= FREE_SLOTS:
            return await ctx.send(
                f'Looks like your free slots are filled! Get rid of some with `{self.client.command_prefix(self.client, ctx.message)[2]}sell`',
                allowed_mentions=discord.AllowedMentions.none())

        if user.jenny < price:
            return await ctx.send(
                f'I\'m afraid you don\'t have enough Jenny to buy this card. Your balance is {user.jenny} while the card costs {price} Jenny'
            )
        try:
            user.add_card(item)
        except Exception as e:
            if isinstance(e, CardLimitReached):
                return await ctx.send(
                    f'Free slots card limit reached (`{FREE_SLOTS}`)! Get rid of one card in your free slots to add more cards with `{self.client.command_prefix(self.client, ctx.message)[2]}sell <card>`',
                    allowed_mentions=discord.AllowedMentions.none())
            else:
                print(e)

        user.remove_jenny(
            price
        )  #Always putting substracting points before giving the item so if the payment errors no item is given
        return await ctx.send(
            f'Successfully bought card number `{card.id}` {card.emoji} for {price} Jenny. Check it out in your inventory with `{self.client.command_prefix(self.client, ctx.message)[2]}book`!',
            allowed_mentions=discord.AllowedMentions.none())
コード例 #11
0
    async def buy_description(self, ctx):
        #Hi! You found a random comment! Now you have to vote for Killua :3 (Also thanks for checking out my code)
        """outsourcing todo buy in smaller functions"""
        list_id = editing[ctx.author.id]
        todo_list = TodoList(list_id)
        user = User(ctx.author.id)
        if user.jenny < 1000:
            return await ctx.send(
                'You don\'t have enough Jenny to buy a thumbnail for your todo list. You need 1000 Jenny'
            )

        step = await ctx.send(
            f'What should the description of your todo list be? (max 200 characters)'
        )

        def check(m):
            return m.author.id == ctx.author.id

        confirmmsg = await self._wait_for_response(step, check)
        if not confirmmsg:
            return

        if len(confirmmsg.content) > 200:
            await ctx.send('Your description can\'t be over 200 characters!')
            return await self.buy_description(ctx)
        user.remove_jenny(1000)
        todo_list.set_property('description', confirmmsg.content)
        return await ctx.send(
            'Congrats! You bought a description for your current todo list')
コード例 #12
0
    async def buy_space(self, ctx):
        # This is the best thing to buy for your todo list
        """outsourcing todo buy in smaller functions"""
        list_id = editing[ctx.author.id]
        todo_list = TodoList(list_id)
        user = User(ctx.author.id)

        if user.jenny < (todo_list.spots * 100 * 0.5):
            return await ctx.send(
                f'You don\'t have enough Jenny to buy more space for your todo list. You need {todo_list["spots"]*100} Jenny'
            )

        if todo_list.spots >= 100:
            return await ctx.send('You can\'t buy more than 100 spots')

        view = ConfirmButton(ctx.author.id, timeout=10)
        msg = await ctx.send(
            f'Do you want to buy 10 more to-do spots for this list? \nCurrent spots: {todo_list.spots} \nCost: {int(todo_list.spots*100*0.5)} points',
            view=view)
        await view.wait()
        await view.disable(msg)

        if not view.value:
            if view.timed_out:
                return await ctx.send(f'Timed out')
            else:
                return await ctx.send(f"Alright, see you later then :3")

        user.remove_jenny(int(100 * todo_list.spots * 0.5))
        todo_list.add_spots(10)
        return await ctx.send(
            'Congrats! You just bought 10 more todo spots for the current todo list!'
        )
コード例 #13
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member, card_id:int) -> None:
        self._permission_check(self.ctx, member)

        if card_id == 0:
            raise CheckFailure("You cannot steal card 0")

        author = User(self.ctx.author.id)
        other = User(member.id)

        self._has_any_card(card_id, other)
        author.remove_card(self.id)
        await self._attack_defense_check(self.ctx, other, card_id)

        stolen = other.remove_card(card_id)
        author.add_card(stolen[0], stolen[1]["fake"])
        await self.ctx.send(f"Stole card number {card_id} successfully!")
コード例 #14
0
    async def discard(self, ctx, card:int):
        """Discard a card you want to get rid of with this command. If you want to throw a fake away, make sure it's in the free slots"""
        
        user = User(ctx.author.id)
        try:
            card = Card(card)
        except CardNotFound:
            return await ctx.send('This card does not exist!')

        if not user.has_any_card(card.id):
            return await ctx.send('You are not in possesion of this card!')

        if card.id == 0:
            return await ctx.send("You cannot discard this card!")

        view = ConfirmButton(ctx.author.id, timeout=20)
        msg = await ctx.send(f"Do you really want to throw this card away? (if you want to throw a fake aware, make sure it's in the free slots (unless it's the only copy you own. You can switch cards between free and restricted slots with `{self.client.command_prefix(self.client, ctx.message)[2]}swap <card_id>`)", view=view, allowed_mentions=discord.AllowedMentions.none())
        await view.wait()
        await view.disable(msg)

        if not view.value:
            if view.timed_out:
                return await ctx.send(f'Timed out!')
            else:
                return await ctx.send(f"Successfully canceled!")

        try:
            user.remove_card(card.id, remove_fake=True, restricted_slot=False)
            # essentially here it first looks for fakes in your free slots and tried to remove them. If it doesn't find any fakes in the free slots, it will remove the first match of the card it finds in free or restricted slots
        except NoMatches:
            user.remove_card(card.id)
        await ctx.send(f'Successfully thrown away card No. `{card.id}`')
コード例 #15
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self) -> None:
        author = User(self.ctx.author.id)
        try:
            self._has_effect_check(author, str(self.id))
        except CheckFailure:
            if not author.count_card(self.id) > 1:
                raise CheckFailure("You don't have another copy of this card to renew the effect")
            view = ConfirmButton(user_id=self.ctx.author.id)
            msg = await self.ctx.send(f"You still have {author.has_effect(str(self.id))[1]} protections left. Do you really want to use this card now and overwrite the current protection?", view=view)
            await view.wait()
            await view.disable(msg)

            if view.timed_out:
                raise CheckFailure("Timed out!")
            elif view.value is False:
                raise CheckFailure("Successfully canceled!")

        if author.has_effect(str(self.id)):
            author.remove_effect(str(self.id))

        # if (amount:=author.count_card(self.id)) > 1:
        #     for i in range(amount):
        #         author.remove_card(self.id)

        author.add_effect(str(self.id), 10)

        await self.ctx.send('Done, you will be automatically protected from the next 10 attacks! You need to keep the card in your inventory until all 10 defenses are used up')
コード例 #16
0
 async def daily(self, ctx):
     """Claim your daily Jenny with this command!"""
     now = datetime.utcnow()
     user = User(ctx.author.id)
     min = 50
     max = 100
     if user.is_premium:
         min *= 2
         max *= 2
     if ctx.guild and Guild(ctx.guild.id).is_premium:
         min *= 2
         max *= 2
     daily = randint(min, max)
     if user.is_entitled_to_double_jenny:
         daily *= 2
     if str(user.daily_cooldown) < str(now):
         user.claim_daily()
         user.add_jenny(daily)
         await ctx.send(
             f'You claimed your {daily} daily Jenny and hold now on to {user.jenny}'
         )
     else:
         cooldown = f"<t:{int(user.daily_cooldown.timestamp())}:R>"
         await ctx.send(
             f'You can claim your daily Jenny the next time in {cooldown}')
コード例 #17
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, card_id:int) -> None:
        self._is_valid_card_check(card_id)

        author = User(self.ctx.author.id)
        author.remove_card(self.id)
        embed = self._get_analysis_embed(card_id)
        await self.ctx.send(embed=embed)
コード例 #18
0
    def _use_check(self, ctx, item:int, args:Optional[Union[discord.Member, int, str]], add_args: Optional[int]) -> None:
        """Makes sure the inputs are valid if they exist"""
        if item in [*DEF_SPELLS, *VIEW_DEF_SPELLS]:
            raise CheckFailure('You can only use this card in response to an attack!')

        try:
            if Card(item).type != "spell":
                raise CheckFailure("You can only use spell cards!")
        except CardNotFound:
            raise CheckFailure("Invalid card id")

        if not item in [x[0] for x in User(ctx.author.id).fs_cards] and not item in [1036]:
            raise CheckFailure('You are not in possesion of this card!')

        if args:
            if isinstance(args, discord.Member):
                if args.id == ctx.author.id:
                    raise CheckFailure('You can\'t use spell cards on yourself')
                elif args.bot:
                    raise CheckFailure("You can't use spell cards on bots")

            if isinstance(args, int):
                if args < 1:
                    raise CheckFailure('You can\'t use an integer less than 1')

        if add_args:
            if add_args < 1:
                raise CheckFailure('You can\'t use an integer less than 1')
コード例 #19
0
    async def meet(self, ctx, user:discord.Member):
        """Meet a user who has recently send a message in this channel to enable certain spell card effects"""

        author = User(ctx.author.id)
        past_users = list()
        if user.bot:
            return await ctx.send('You can\'t interact with bots with this command')
        async for message in ctx.channel.history(limit=20):
            if message.author.id not in past_users:
                past_users.append(message.author.id)

        if not user.id in past_users:
            return await ctx.send('The user you tried to approach has not send a message in this channel recently')

        if user.id in author.met_user:
            try:
                await ctx.message.delete()
            except discord.HTTPException:
                pass
            return await ctx.send(f'You already have `{user}` in the list of users you met, {ctx.author.name}', delete_after=2, allowed_mentions=discord.AllowedMentions.none())

        author.add_met_user(user.id)
        try:
            await ctx.message.delete()
        except discord.HTTPException:
            pass
        return await ctx.send(f'Done {ctx.author.mention}! Successfully added `{user}` to the list of people you\'ve met', delete_after=5, allowed_mentions=discord.AllowedMentions.none())
コード例 #20
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, page:int) -> None:
        author = User(self.ctx.author.id)

        if page > 6 or page < 1:
            raise CheckFailure('You need to choose a page between 1 and 6')
        self._has_effect_check(author, f"page_protection_{page}")
        author.remove_card(self.id)
        author.add_effect(f'page_protection_{page}', datetime.utcnow()) # The value doesn't matter here
        await self.ctx.send(f'Success! Page {page} is now permanently protected')
コード例 #21
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, card_id:int) -> None:
        self._is_valid_card_check(card_id)

        if card_id == 0:
            raise CheckFailure("Redacted card!")

        User(self.ctx.author.id).remove_card(self.id)

        embed = self._get_list_embed(card_id)
        await self.ctx.send(embed=embed)
コード例 #22
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self) -> None:
        author = User(self.ctx.author.id)
        self._is_full_check(author)

        target = random.choice([x['_id'] for x in items.find({'type': 'normal', "available": True}) if x['rank'] != 'SS' and x["_id"] != 0]) # random card for lottery
        author.remove_card(self.id)
        self._is_maxed_check(target)
        author.add_card(target)

        await self.ctx.send(f'Successfully added card No. {target} to your inventory')
コード例 #23
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member) -> None:
        self._permission_check(self.ctx, member)

        author = User(self.ctx.author.id)
        other = User(member.id)

        self._has_cards_check(other.all_cards)
        self._has_other_card_check(author.all_cards)

        target_card = random.choice([x[0] for x in other.all_cards if x[0] != 1008 and x[0] != 0])
        await self._attack_defense_check(self.ctx, other, target_card)

        author.remove_card(self.id)
        removed_card_other = other.remove_card(target_card)
        removed_card_author = author.remove_card(random.choice([x[0] for x in author.all_cards if x[0] != 0]))
        other.add_card(removed_card_author[0], removed_card_author[1]["fake"])
        author.add_card(removed_card_other[0], removed_card_other[1]["fake"])

        await self.ctx.send(f'Successfully swapped cards! Gave {member} the card `{removed_card_author[0]}` and took card number `{removed_card_other[0]}` from them!')
コード例 #24
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, card_id:int) -> None:
        self._is_valid_card_check(card_id)

        if card_id > 99 or card_id < 1:
            raise CheckFailure(f"You can only use \"{self.name}\" on a card with id between 1 and 99!")

        author = User(self.ctx.author.id)

        author.remove_card(self.id)
        author.add_card(card_id, True)
        await self.ctx.send(f'Created a fake of card No. {card_id}! Make sure to remember that it\'s a fake, fakes don\'t count towards completion of the album')
コード例 #25
0
    async def lootbox(self, ctx, box: int):
        """Buy a lootbox with this command"""
        if not box in LOOTBOXES or not LOOTBOXES[box]["available"]:
            return await ctx.send("This lootbox is not for sale!")

        user = User(ctx.author.id)

        if user.jenny < (price := LOOTBOXES[box]["price"]):
            return await ctx.send(
                f"You don't have enough jenny to buy this box (You have: {user.jenny}, cost: {price})"
            )
コード例 #26
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, card_id:int) -> None:
        user = User(self.ctx.author.id)

        if not user.has_any_card(card_id, False):
            raise CheckFailure('Seems like you don\'t own this card You already need to own a (non-fake) copy of the card you want to duplicate')

        self._is_maxed_check(card_id)
        user.remove_card(self.id)
        user.add_card(card_id, clone=True)

        await self.ctx.send(f'Successfully added another copy of {card_id} to your book!') 
コード例 #27
0
    def _getmember(self, user: Union[discord.Member,
                                     discord.User]) -> discord.Embed:
        """ a function to handle getting infos about a user for less messy code """
        joined = self.client.convert_to_timestamp(user.id)

        info = User(user.id)
        flags = [USER_FLAGS[x[0]] for x in user.public_flags if x[1]]
        if (user.avatar and user.avatar.is_animated()) or len([
                x for x in self.client.guilds
                if user.id in [y.id for y in x.premium_subscribers]
        ]) > 0:  # A very simple nitro check that is not too accurate
            flags.append(USER_FLAGS["nitro"])
        badges = [(KILLUA_BADGES[PREMIUM_ALIASES[x]]
                   if x in PREMIUM_ALIASES.keys() else KILLUA_BADGES[x])
                  for x in info.badges]

        if str(datetime.utcnow()) > str(info.daily_cooldown):
            cooldown = 'Ready to claim!'
        else:
            cooldown = f"<t:{int(info.daily_cooldown.timestamp())}:R>"

        embed = discord.Embed.from_dict({
            'title':
            f'Information about {user}',
            'description':
            f'{user.id}\n{" ".join(flags)}',
            "fields": [{
                "name": "Killua Badges",
                "value": " ".join(badges) if len(badges) > 0 else "No badges",
                "inline": False
            }, {
                "name": "Jenny",
                "value": str(info.jenny),
                "inline": False
            }, {
                "name": "Account created at",
                "value": joined,
                "inline": False
            }, {
                "name": "daily cooldown",
                "value": cooldown or "Never claimed `k!daily` before",
                "inline": False
            }],
            'thumbnail': {
                'url': str(user.avatar.url) if user.avatar else None
            },
            "image": {
                "url": user.banner.url if user.banner else None
            },
            'color':
            0x1400ff
        })
        return embed
コード例 #28
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member) -> None:
        other = User(member.id)
        author = User(self.ctx.author.id)

        tbr = [x for x in other.all_cards if x[1]["fake"] or x[1]["clone"]]

        if len(tbr) == 0:
            raise CheckFailure("This user does not have any cards you could target with this spell!")

        author.remove_card(self.id)

        rs_tbr = [x for x in other.rs_cards if x[1]["fake"] is True or x[1]["clone"] is True]
        fs_tbr = [x for x in other.fs_cards if x[1]["fake"] is True or x[1]["clone"] is True]

        for c in rs_tbr:
            other.rs_cards.remove(c)
        for c in fs_tbr:
            other.fs_cards.remove(c)

        other._update_val('cards', {'rs': other.rs_cards, 'fs': other.fs_cards, 'effects': other.effects}) 
        await self.ctx.send(f'Successfully removed all cloned and fake cards from `{member}`. Cards removed in total: {len(tbr)}')
コード例 #29
0
    async def book(self, ctx, page:int=1):
        """Allows you to take a look at your cards"""
        user = User(ctx.author.id)

        if len(user.all_cards) == 0:
            return await ctx.send('You don\'t have any cards yet!')

        if page:
            if page > 7+math.ceil(len(user.fs_cards)/18) or page < 1:
                return await ctx.send(f'Please choose a page number between 1 and {6+math.ceil(len(user.fs_cards)/18)}')

        async def make_embed(page, embed, pages):
            return await Book(self.client.session).create(ctx.author, page)
        return await Paginator(ctx, page=page, func=make_embed, max_pages=6+math.ceil(len(user.fs_cards)/18), has_file=True).start()
コード例 #30
0
    async def hunt(self, ctx, end:str=None):
        """Go on a hunt! The longer you are on the hunt, the better the rewards!"""
        
        user = User(ctx.author.id)
        has_effect, value = user.has_effect('hunting')

        if end:

            if end.lower() == 'time':
                if not has_effect:
                    return await ctx.send('You are not on a hunt yet!')
                
                return await ctx.send(f'You\'ve started hunting <t:{int(value.timestamp())}:R>.')

            if not end.lower() == 'end':
                pass
            elif has_effect is True:
                difference = datetime.utcnow() - value
                if int(difference.seconds/60/60+difference.days*24*60*60) < 12: # I don't think timedelta has an hours or minutes property :c
                    return await ctx.send('You must be at least hunting for twelve hours!')

                minutes = int(difference.seconds/60+difference.days*24*60)
                score = minutes/10080 # There are 10080 minutes in a week if I'm not completely wrong
                
                rewards = self._construct_rewards(score)
                formatted_rewards, formatted_text, hit_limit = self._format_rewards(rewards, user, score)
                text = f'You\'ve started hunting <t:{int(value.timestamp())}:R>. You brought back the following items from your hunt: \n\n'
                if hit_limit:
                    text += f":warning: Your free slot limit has been reached! Sell some cards with `{self.client.command_prefix(self.client, ctx.message)[2]}sell` :warning:\n\n"

                if hit_limit and len(user.fs_cards) == 40:
                    text += f"Could not carry anything from your hunt in your free slots so you gained no cards.."

                embed = discord.Embed.from_dict({
                    'title': 'Hunt returned!',
                    'description': text + "\n".join(formatted_text),
                    'color': 0x1400ff
                })
                user.remove_effect('hunting')
                user.add_multi(*formatted_rewards)
                return await ctx.send(embed=embed)
                
            elif end.lower() == 'end': 
                return await ctx.send(f'You aren\'t on a hunt yet! Start one with `{self.client.command_prefix(self.client, ctx.message)[2]}hunt`', allowed_mentions=discord.AllowedMentions.none())

        if has_effect:
            return await ctx.send(f'You are already on a hunt! Get the results with `{self.client.command_prefix(self.client, ctx.message)[2]}hunt end`', allowed_mentions=discord.AllowedMentions.none())
        user.add_effect('hunting', datetime.utcnow())
        await ctx.send('You went hunting! Make sure to claim your rewards at least twelve hours from now, but remember, the longer you hunt, the more you get')