Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python I';i’我想在Discord.py里做一个工作指令,在那里你可以通过回答一个数学问题来赚钱,但我不能让它工作_Python_Python 3.x_Discord.py_Discord.py Rewrite - Fatal编程技术网

Python I';i’我想在Discord.py里做一个工作指令,在那里你可以通过回答一个数学问题来赚钱,但我不能让它工作

Python I';i’我想在Discord.py里做一个工作指令,在那里你可以通过回答一个数学问题来赚钱,但我不能让它工作,python,python-3.x,discord.py,discord.py-rewrite,Python,Python 3.x,Discord.py,Discord.py Rewrite,好的,我正在使用SQLite数据库来实现这个机器人货币系统,我正在尝试做一个新的命令,它会给你一个数学问题,如果你回答正确,你就可以赚钱。现在我的问题是,即使我输入了正确的答案,它也会告诉我我错了。这是我的代码: def check(author): def inner_check(message): if message.author != author: return False try: int(mes

好的,我正在使用SQLite数据库来实现这个机器人货币系统,我正在尝试做一个新的命令,它会给你一个数学问题,如果你回答正确,你就可以赚钱。现在我的问题是,即使我输入了正确的答案,它也会告诉我我错了。这是我的代码:

def check(author):
    def inner_check(message):
        if message.author != author:
            return False
        try:
            int(message.content)
            return True
        except ValueError:
            return False
    return inner_check


@client.command(pass_context=True)
async def work(ctx):
    USER_ID = ctx.message.author.id
    no1 = random.randint(1,1000)
    no2 = random.randint(1,1000)
    answer = no1 + no2
    await ctx.send(f'What is **{no1}** + **{no2}**?')
    msg = await client.wait_for('message', check=check(ctx.author), timeout=None)
    if msg.content == answer:
        SQL.execute('update Accounts set balance = balance + ? where user_id = ?', (100, USER_ID))
        await ctx.send(f'Good work, {ctx.message.author.mention}. You earned 100 {C_NAME}')
    else:
        SQL.execute('update Accounts set balance = balance - ? where user_id = ?', (100, USER_ID))
        await ctx.send(f"Terrible work, {ctx.message.author.mention}. I'm cutting your paycheck and you lost 100 {C_NAME}")

msg.content
替换为
int(msg.content)
answer
替换为
str(answer)

如果
答案正确,我们将返回良好的工作。

msg.content
替换为
int(msg.content)
answer
替换为
str(answer)


如果回答是正确的,我们将返回良好的结果。

您正在对照int检查字符串。消息内容始终是字符串。您正在对照int检查字符串。消息内容始终是字符串。
if msg.content == answer: