示例#1
0
    async def transfer(self, ctx, user: discord.Member, amount: str):
        author_cash, _ = await get_stats(ctx, ctx.author.id)
        target_cash, _ = await get_stats(ctx, user.id, True)

        amount = get_number(amount, author_cash)

        async with self.bot.db.acquire() as conn:
            async with conn.transaction():
                await self.bot.db.execute("UPDATE economy SET cash = cash - $1 WHERE guild_id = $2 AND user_id = $3",
                                          amount, ctx.guild.id, ctx.author.id)
                await self.bot.db.execute("UPDATE economy SET cash = cash + $1 WHERE guild_id = $2 AND user_id = $3",
                                          amount, ctx.guild.id, user.id)

        await ctx.send(embed=ctx.embed(description=f'You gave {user.mention} **${humanize.intcomma(amount)}**'))
示例#2
0
    async def blackjack(self, ctx, bet: str):
        """Play a game of blackjack.
        If you do not respond, the bot will choose hit if your value is under 17, and hit otherwise.

        Arguments:
            `bet`: The bet you want to play. This takes from your wallet."""
        cash, _ = await get_stats(ctx, ctx.author.id)
        amount = get_number(bet, cash)
        query = """
            UPDATE economy SET cash = cash - $1
            WHERE guild_id = $2 AND user_id = $3
            """
        await self.bot.db.execute(query, amount, ctx.guild.id, ctx.author.id)

        bj = Blackjack(ctx, amount)
        await bj.start()
示例#3
0
    async def withdraw(self, ctx, amount: str):
        cash, bank = await get_stats(ctx, ctx.author.id)

        amount = get_number(amount, bank)
        if amount == 0:
            return await ctx.send(embed=ctx.embed(description="You have no cash."))

        query = (
            """
            UPDATE economy SET cash = cash + $1, bank = bank - $1
            WHERE guild_id = $2 AND user_id = $3
            """
        )

        await self.bot.db.execute(query, amount, ctx.guild.id, ctx.author.id)
        await ctx.send(embed=ctx.embed(description=f'You withdrew **${humanize.intcomma(amount)}** from your bank.'))
示例#4
0
    async def slots(self, ctx, bet: str):
        cash, _ = await get_stats(ctx, ctx.author.id)
        amount = get_number(bet, cash)

        emojis = ("⭐", "🎖️", "🎁")
        e = random.choices(emojis, k=3)

        if e[0] == e[1] == e[2]:
            total = amount
            result = f"🎉 All three match!  **${total}**"
        elif (e[0] == e[1]) or (e[0] == e[2]) or (e[1] == e[2]):
            total = int(amount * 0.5)
            result = f"🎉 Two in a row! **${total}**"
        else:
            total = -amount
            result = f"😥 No match. **${total}**"

        query = """
            UPDATE economy SET cash = cash + $1
            WHERE guild_id = $2 AND user_id = $3
            """
        await self.bot.db.execute(query, total, ctx.guild.id, ctx.author.id)
        await ctx.send(embed=ctx.embed(
            description=f"{' '.join(e)}\n\n{result}"))