async def betaal(self, ctx, user: discord.User, coins: int): if ctx.author == user: return await ctx.send( f'Hey {ctx.author.mention} je kan niet jezelf betalen!') if coins < 1: return await ctx.send( f'Hey {ctx.author.mention} je moet minimaal `1` coin geven!') embeds = self.bot.get_cog('Embeds') betaler = database.Cosplayer(ctx.author.id) ontvanger = database.Cosplayer(user.id) if await betaler.get_coins() < coins: return await ctx.send( f'Hey {ctx.author.mention} je hebt niet genoeg coins!') if await ontvanger.update_coins(coins) and await betaler.update_coins( -abs(coins)): return await ctx.send( f'Hey {ctx.author.mention} je hebt {user.name} `{coins}` gegeven' ) else: return await ctx.send(embed=await embeds.error())
async def daily(self, ctx): cosplayer = database.Cosplayer(ctx.author.id) embeds = self.bot.get_cog('Embeds') if await cosplayer.update_coins(500): return await ctx.send( f'Hey {ctx.author.mention} je hebt `500` coins gekregen!') else: return await ctx.send(embed=await embeds.error())
async def coins(self, ctx, user: discord.User = None): if not user: user = ctx.author cosplayer = database.Cosplayer(user.id) coins = await cosplayer.get_coins() if user == ctx.author: return await ctx.send( f'Hey {ctx.author.mention} je hebt `{coins}` coins') return await ctx.send( f'Hey {ctx.author.mention} {user.name} heeft `{coins}` coins')
async def doneer(self, ctx, user: discord.User, coins: int): cosplayer = database.Cosplayer(user.id) embeds = self.bot.get_cog('Embeds') if await cosplayer.update_coins(coins): if user == ctx.author: return await ctx.send( f'Hey {ctx.author.mention} je hebt jezelf `{coins}` gegeven!' ) return await ctx.send( f'Hey {ctx.author.mention} je hebt {user.name} `{coins}` gegeven!' ) else: return await ctx.send(embed=await embeds.error())
async def warn(self, ctx, users: commands.Greedy[discord.User], *, warning='Geen redenen gegeven'): await ctx.message.delete() embeds = self.bot.get_cog("Embeds") for user in users: cosplayer = database.Cosplayer(user.id) if await cosplayer.add_warning( f'{ctx.author.name}#{ctx.author.discriminator}', warning): channel = self.bot.get_channel(719263750426984538) await ctx.send( embed=await embeds.warning_short(user, ctx.author)) await channel.send( embed=await embeds.warning(user, warning, ctx.author)) else: await ctx.send(embed=await embeds.error()) break
async def warnings(self, ctx, user: discord.User = None): await ctx.message.delete() embeds = self.bot.get_cog('Embeds') if not user: return await ctx.send( embed=await embeds.explain('warnings', '`warnings @hope`')) cosplayer = database.Cosplayer(user.id) user_warnings = await cosplayer.get_warnings() if user_warnings: message = await ctx.send(embed=await embeds.loading()) emoji_list = ('◀', '❌', '▶') menu_number = 0 for emoji in emoji_list: await message.add_reaction(emoji=emoji) def check(reaction, main_user): return main_user == ctx.author and str(reaction.emoji) in emoji_list and reaction.message.id == \ message.id await message.edit( embed=await embeds.warnings(user, user_warnings, menu_number)) while True: try: reaction, main_user = await self.bot.wait_for( 'reaction_add', timeout=20, check=check) await message.remove_reaction(str(reaction.emoji), ctx.author) if str(reaction.emoji) == '◀' and menu_number > 0: menu_number -= 1 if str(reaction.emoji ) == '▶' and menu_number != len(user_warnings) - 1: menu_number += 1 if str(reaction.emoji) == '❌': await cosplayer.remove_warning( user_warnings[menu_number][0]) user_warnings = await cosplayer.get_warnings() menu_number = 0 if user_warnings: await message.edit(embed=await embeds.warnings( user, user_warnings, menu_number)) else: await message.edit(embed=await embeds.nowarning(user)) await asyncio.sleep(10) break except asyncio.TimeoutError: break await message.delete() else: message = await ctx.send(embed=await embeds.nowarning(user)) await asyncio.sleep(10) await message.delete()