Discord 使用命令无法正常工作

时间:2021-07-14 15:29:38

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

@client.command()
async def ause(ctx, *, item=None):
    res = await sell_this(ctx.author, item, 1)
    
    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! in 15 seconds 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' in 15 seconds 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]:
        print("OUT!")
    

    def check(message):
            return message.author == ctx.author
    
    try:
            await ctx.send(random.choice(responses))
            response = await client.wait_for('message', check=check, timeout=6)
            if responses[0]:
                if response.content == "COMING WAIT ME!":
                    await ctx.send(f'**{random.choice(responses)}**')
                    users[str(user.id)]["wallet"] += earnings
                else:
                    await ctx.send(f"**DIVORCED ?**! Your wife took {bad} coins from you. and she took your lovely kid ?**")
                    users[str(user.id)]["wallet"] -= bad
    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 responses[1]:
                        if response.content == "WAKE UP WAKE UP":
                            await ctx.send(f'**{random.choice(responses)}**')
                            users[str(user.id)]["wallet"] += earnings
                        else:
                            await ctx.send(f"**MISSED MEETIN ?**! I  took {bad} coins from you. and your momma dis-owned you ?**")
                            users[str(user.id)]["wallet"] -= bad
                            with open("bank.json", "w") as f:
                                json.dump(users, f, indent=4)            
                    if responses[2]:
                        if response.content == "I LOVE TIME":
                            users[str(user.id)]["wallet"] += earnings
                        else:
                            await ctx.send(f"**FBI RAIDED YOUR HOME ⚠**! FBI JAILED YOU FOR 45 years and  took {bad} coins from you. ?**")
                            users[str(user.id)]["wallet"] -= bad
                            with open("bank.json", "w") as f:
                                json.dump(users, f, indent=4)                   

此代码基本上用于使用一个项目,我希望它选择一个随机响应/问题,例如,如果第一个被选中并且玩家输入“IM COMING WAIT!”我想要它给他/她的钱,但不知道为什么它不起作用。

所以首先 它不是选择随机问题 它不工作 什么都没有正常运行

0 个答案:

没有答案