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!')
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')