在不和谐经济系统中未触发使用命令

时间:2021-07-20 05:11:05

标签: python python-3.x discord discord.py


@client.command()
async def use(ctx, *, item=None):

    if item == "watch" or "Watch":
        res = await sell_this(ctx.author, item, 1)

        if res[1] == 3:
            await ctx.send(f"You don't have watch in your bag.")
            return
        responses = ["You looked at the watch and you realise it's 9:00PM and you have a date with a girl say COMING WAIT ME! before she kills you",
                     "You looked at the watch and you remmeber you have a meeting tomorrow and it's 2:00AM and then you realise it's a dream say  'WAKE UP WAKE UP' before you miss the interview",
                     "You looked at the watch and you realised it wasted 1 minute of your time say 'I LOVE TIME' before FBI comes raid your home", ]

        # VARiABLES
        users = await get_bank_data()
        user = ctx.author
        earnings = random.randrange(0, 6200)
        bad = random.randrange(0, 4200)

        if not res[0]:
            if res[1] == 1:
                await ctx.send("That Object isn't there!")
                return
            if res[1] == 2:
                await ctx.send(f"You don't have {item} in your bag.")
                return
            if res[1] == 3:
                await ctx.send(f"You don't have {item} in your bag.")
                return

        wat = random.choice(responses)
        await ctx.send(wat)

        def check(message):
            return message.author == ctx.author
        if wat == responses[0]:
            try:
                response = await client.wait_for('message', check=check, timeout=8)
                if response.content == "COMING WAIT ME!":
                    users[str(user.id)]["wallet"] += earnings
                    return await ctx.send(f"**Coming wait me {earnings} coins**")
                else:
                    users[str(user.id)]["wallet"] -= bad

                    return await ctx.send(f"**DIVORCED ?**! Your wife took {bad} coins from you. and she took your lovely kid ?**")
            except:
                await ctx.send(f"**DIVORCED ?**! Your wife took {bad} coins from you. and she took your lovely kid ?")
                users[str(user.id)]["wallet"] -= bad

                with open("bank.json", "w") as f:
                    json.dump(users, f, indent=4)

        if wat == responses[1]:
            try:
                response = await client.wait_for('message', check=check, timeout=8)
                if response.content == "WAKE UP WAKE UP":
                    users[str(user.id)]["wallet"] += earnings
                    return await ctx.send(f"**AMAZING JOB you didn't miss you meeting good job here take {earnings} coins :))**")
                else:
                    users[str(user.id)]["wallet"] -= bad
                    return await ctx.send(f"**MISSED MEETING ?**! You missed your meeting and your wife took your 120 lovely kids and stole {bad} coins from you ?")

            except:
                await ctx.send(f"**MISSED MEETING ?**! You missed your meeting and your wife took your 120 lovely kids and stole {bad} coins from you ?")
                users[str(user.id)]["wallet"] -= bad

                with open("bank.json", "w") as f:
                    json.dump(users, f, indent=4)

        if wat == responses[2]:
            try:
                response = await client.wait_for('message', check=check, timeout=8)
                if response.content == "I LOVE TIME":
                    users[str(user.id)]["wallet"] += earnings
                    return await ctx.send(f"**Good job, FBI gave you {earnings} coins for being a good boy**")
                else:
                    users[str(user.id)]["wallet"] -= bad
                    return await ctx.send(f"**JAiLED! ??**! FBI Jailed you and took {bad} coins from you. and you are now jailed?**")

            except:
                await ctx.send(f"**JAiLED! ??**! FBI Jailed you and took {bad} coins from you. and you are now jailed?**")
                users[str(user.id)]["wallet"] -= bad

                with open("bank.json", "w") as f:
                    json.dump(users, f, indent=4)

    if item == "lolipop" or "Lolipop":
        res = await sell_this(ctx.author, item, 1)

        if res[1] == 3:
            await ctx.send(f"You don't have lolipop in your bag.")
            return
        questions = ["You used your lolipop and you enjoyed it",
                     "Your lolipop cried.", ]
        # VARiABLES
        users = await get_bank_data()
        user = ctx.author
        earnings = random.randrange(0, 6200)
        bad = random.randrange(0, 4200)

        if not res[0]:
            if res[1] == 1:
                await ctx.send("That Object isn't there!")
                return
            if res[1] == 2:
                await ctx.send(f"You don't have {item} in your bag.")
                return
            if res[1] == 3:
                await ctx.send(f"You don't have {item} in your bag.")
                return

        wat = random.choice(questions)
        return await ctx.send(wat)

    if item == "laptop" or "Laptop":
        res = await sell_this(ctx.author, item, 1)

        if res[1] == 3:
            await ctx.send(f"You don't have watch in your bag.")
            return

        randomword = ["ytoueb", "poitsfy", "suimc", "ssa", "fcuk"]
        chuse = random.choice(randomword)
        mustchoose = ["You looked at the laptop and you saw there is a hot deal but you have 50/50 chance of winning it say 'START' to take the deal",
                      f"You looked at the watch and you realised it wasted 1 minute of your ugly face Complete the word to earn money or u lost money the word is '`{chuse}`'", ]

        # VARiABLES
        users = await get_bank_data()
        user = ctx.author
        earnings = random.randrange(0, 6200)
        bad = random.randrange(0, 4200)

        if not res[0]:
            if res[1] == 1:
                await ctx.send("That Object isn't there!")
                return
            if res[1] == 2:
                await ctx.send(f"You don't have {item} in your bag.")
                return
            if res[1] == 3:
                await ctx.send(f"You don't have {item} in your bag.")
                return

        chancebot = random.choice(range(0, 10))
        chanceme = random.choice(range(0, 10))
        wat = random.choice(mustchoose)
        await ctx.send(wat)

        def check(message):
            return message.author == ctx.author
        if wat == mustchoose[0]:
            try:
                response = await client.wait_for('message', check=check, timeout=8)
                if response.content == "START":
                    if chancebot > chanceme:
                        lostembed = discord.Embed(
                            title="**You LOST**", colour=discord.Color.red())
                        lostembed.add_field(
                            name=f"Your chance:", value=f"`{chanceme}`")
                        lostembed.add_field(
                            name=f"My chance:", value=f"`{chanceme}`")
                        await ctx.send(embed=lostembed)
                        await ctx.send(f"You lost {earnings} coins :(")
                        users[str(user.id)]["wallet"] -= earnings
                    if chanceme > chancebot:
                        wonembed = discord.Embed(
                            title="**You WON!**", colour=discord.Color.green())
                        wonembed.add_field(
                            name=f"Your chance:", value=f"`{chanceme}`")
                        wonembed.add_field(
                            name=f"My chance:", value=f"`{chanceme}`")
                        await ctx.send(embed=wonembed)
                        await ctx.send(f"You WON {earnings} coins LESH GOOOO")
                        users[str(user.id)]["wallet"] += earnings
                else:
                    users[str(user.id)]["wallet"] -= bad
                    return await ctx.send(f"**Wrong... :(( lost {bad} for participating**")
            except:
                await ctx.send(f"**Time is out you lost {bad} coins for participating**")
                users[str(user.id)]["wallet"] -= bad

                with open("bank.json", "w") as f:
                    json.dump(users, f, indent=4)

        if wat == mustchoose[1]:
            if chuse == randomword[0]:
                try:
                    response = await client.wait_for('message', check=check, timeout=20)
                    if response.content == "youtube":
                        users[str(user.id)]["wallet"] += earnings
                        return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
                    else:
                        users[str(user.id)]["wallet"] -= bad
                        return await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")

                except:
                    await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")
                    users[str(user.id)]["wallet"] -= bad

            if chuse == randomword[1]:
                try:
                    response = await client.wait_for('message', check=check, timeout=20)
                    if response.content == "spotify":
                        users[str(user.id)]["wallet"] += earnings
                        return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
                    else:
                        users[str(user.id)]["wallet"] -= bad
                        return await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")

                except:
                    await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")
                    users[str(user.id)]["wallet"] -= bad

            if chuse == randomword[2]:
                try:
                    response = await client.wait_for('message', check=check, timeout=20)
                    if response.content == "music":
                        users[str(user.id)]["wallet"] += earnings
                        return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
                    else:
                        users[str(user.id)]["wallet"] -= bad
                        return await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")

                except:
                    await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")
                    users[str(user.id)]["wallet"] -= bad

            if chuse == randomword[3]:
                try:
                    response = await client.wait_for('message', check=check, timeout=8)
                    if response.content == "ass":
                        users[str(user.id)]["wallet"] += earnings
                        return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
                    else:
                        users[str(user.id)]["wallet"] -= bad
                        return await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")

                except:
                    await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")
                    users[str(user.id)]["wallet"] -= bad

            if chuse == randomword[4]:
                try:
                    response = await client.wait_for('message', check=check, timeout=8)
                    if response.content == "fuck":
                        users[str(user.id)]["wallet"] += earnings
                        return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
                    else:
                        users[str(user.id)]["wallet"] -= bad
                        return await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")

                except:
                    await ctx.send(f"**WRONG WORD ?**! Very very bad job.. i will steal {bad} coins from you :P")
                    users[str(user.id)]["wallet"] -= bad
                    with open("bank.json", "w") as f:
                        json.dump(users, f, indent=4)

好吧,所以这段代码基本上是为了使用一个项目,它可以工作,但即使我说*使用笔记本电脑,它也会不断发送手表问题,所以如果我说*使用笔记本电脑,它会首先发送手表问题,然后我认为是棒棒糖问题笔记本电脑问题如何解决? 一切都值得赞赏 再一次,我只想让它可以工作<3

1 个答案:

答案 0 :(得分:1)

正如@lemonhead 在他的评论中提到的

<块引用>

从python真实性的角度来看,非空字符串子句实际上读作始终为真的语句。因此,当您说 maps.fitbounds() 时,它与说 if item == "laptop" or "Laptop" 相同;它总是评估为 True

正确的方法是if item == "laptop" or True,但还有其他一些方法可以做到:

if item == "watch" or item == "Watch" 将字符串全部转换为小写,.lower() -> "WaTch"

"watch"

如果您有多个选项,例如“笔记本电脑”和“笔记本电脑”,if item.lower() == "watch": 会变得超长。

相反,您可以检查该项目是否为 if item.lower() == "laptop" or item.lower() == "notebook" 列表

in