async def on_guild_join(guild): print(f'Joined a new guild: {guild.name}\nFetching members!') guild.fetch_members() for member in guild.members: if not member.bot: database.doesExist(member.id) print(f"Done fetching and importing members for: {guild.name}")
async def betflip(self, ctx, opcion = 'c', amount:float = None): if not database.doesExist(ctx.author.id): print(f'User {ctx.author.name} does not exist in database!') if amount is None: if self.coinflip() == 0: await ctx.send('Ha salido:\n`CARA`') else: await ctx.send('Ha salido:\n`CRUZ`') else: if opcion.lower() == 'c': eleccion = 0 elif opcion.lower() == 'x': eleccion = 1 if amount > 0: if amount <= database.getBalance(ctx.author.id): database.quitarDinero(ctx.author.id, amount) sale = self.coinflip() if sale == 0: await ctx.send('Ha salido:\n`CARA`') else: await ctx.send("Ha salido:\n`CRUZ`") if eleccion == sale: await ctx.send(f"**Has ganado: `{float(amount) * 2} €`**") database.darDinero(ctx.author.id, amount * 2) else: await ctx.send("Has **PERDIDO!**") else: await ctx.send("No tienes tanto dinero!")
async def on_ready(): await bot.change_presence(status=discord.Status.idle, activity=game) bot.load_extension('COGS.comandosBasicos') bot.load_extension('COGS.Economia') bot.load_extension('COGS.animanga') bot.load_extension('COGS.comandoHelp') bot.load_extension('COGS.comandosPesca') print('fetching and registering all guild members...') guild: discord.Guild for guild in bot.guilds: guild.fetch_members() for member in guild.members: if not member.bot: database.doesExist(member.id) print('-----------------------Done!------------------------') print('logged as {0.user}\nThis bot is currently in {1} guilds'.format( bot, len(bot.guilds)))
async def pedircredito(self, ctx, cuanto:float = None): if not database.doesExist(ctx.author.id): print(f'User {ctx.author.name} does not exist in database!') if cuanto is None: await ctx.send('Cantidad no válida!', delete_after=2) return debt = database.getDeuda(ctx.author.id) if debt < 2000.0: if cuanto > 0 and cuanto < (2000 - debt): database.pedirCredito(ctx.author.id, cuanto) await ctx.send(f"Te han sido concedidos:\n`{cuanto} €`") else: await ctx.send('Tienes mas de 2000€ de deuda, paga primero!', delete_after=2)
async def pagarcredito(self, ctx, cuanto:float = None): if not database.doesExist(ctx.author.id): print(f'User {ctx.author.name} does not exist in database!') if cuanto is None: await ctx.send("Cantidad no válida!", delete_after=2) return balance = database.getBalance(ctx.author.id) deuda = database.getDeuda(ctx.author.id) if balance < cuanto: await ctx.send("No tienes tanto dinero en tu cuenta!") return else: if deuda >= cuanto: database.pagarCredito(ctx.author.id, cuanto) await ctx.send(f"Has pagado:\n`{cuanto} €`") else: await ctx.send(f"Eso es más dinero del que debes, tu deuda es:\n`**{deuda}**`")
async def betroll(self, ctx, amount:float = None): if not database.doesExist(ctx.author.id): print(f'User {ctx.author.name} does not exist in database!') if amount is None or amount <= 0: await ctx.send("No has apostado nada!") return if amount <= database.getBalance(ctx.author.id): roll = self.rolldice(100) database.quitarDinero(ctx.author.id, amount) await ctx.send(f"Ha salido:\n`{roll}!`") if roll < 66: await ctx.send('No has ganado nada!') elif roll >= 66 and roll < 90: await ctx.send(f'**Has ganado: `{float(amount) * 2} €`**') database.darDinero(ctx.author.id, amount * 2) elif roll >=90 and roll < 100: await ctx.send(f"**Has ganado: `{float(amount) * 4} €`**") database.darDinero(ctx.author.id, amount * 4) elif roll == 100: await ctx.send(f"***damn.*\n**Has ganado: `{float(amount) * 10} €!**`") database.darDinero(ctx.author.id, amount * 10) else: await ctx.send("No tienes tanto dinero!", delete_after=2)
async def on_member_join(member): print( f'NEW MEMBER in: {member.guild.name}\nName: {member.name} --> Importing to database!' ) if not member.bot: database.doesExist(member.id)
async def deuda(self, ctx, member:discord.Member = None): if not database.doesExist(ctx.author.id): print(f'User {ctx.author.name} does not exist in database!') if member is None: member = ctx.author await ctx.send(f"{member.mention} debe:\n`{database.getDeuda(member.id)} €`")