Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/17.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 如何使用discord bot正确调用值_Python_Discord_Bots - Fatal编程技术网

Python 如何使用discord bot正确调用值

Python 如何使用discord bot正确调用值,python,discord,bots,Python,Discord,Bots,对你们这些聪明人来说这是个简单的问题,但我似乎无法解决这个问题。 当我尝试更改函数中的值时,当脚本再次运行时,它会(显然)将其重置回其原始值。 我忘记了如何调用函数外部的值 @client.event async def on_message(message): syntax_error = 0 if message.content.startswith('--mute'): mutestatus = False #The problem if

对你们这些聪明人来说这是个简单的问题,但我似乎无法解决这个问题。 当我尝试更改函数中的值时,当脚本再次运行时,它会(显然)将其重置回其原始值。 我忘记了如何调用函数外部的值

@client.event
async def on_message(message):
    syntax_error = 0

    if message.content.startswith('--mute'):
        mutestatus = False #The problem
        if mutestatus:
            await message.channel.send(">>> **I am muted, you can un-mute me by typing `--unmute`**")
        else:
            mutestatus = True #Also the problem
            await message.channel.send(">>> **I am now muted, you can un-mute me by typing `--unmute`**")
这里是我的版本,如何修复(显然)不起作用的问题

mutestatus = False #My version of the fixed problem.

@client.event
async def on_message(message, mutestatus):
    syntax_error = 0

    if message.content.startswith('--mute'):
        if mutestatus:
            await message.channel.send(">>> **I am muted, you can un-mute me by typing `--unmute`**")
        else:
            mutestatus = True
            await message.channel.send(">>> **I am now muted, you can un-mute me by typing `--unmute`**")

请不要指出这是多么容易。我觉得很抱歉不得不发布这个。你为什么要用这个?将其添加到
mute
unmute
命令中。这会更有意义,而且你不必使用布尔变量documents@SecretLlyod哦,不!我可以帮助您重新创建这些命令。只需将我添加到discord(沉默的创建者#2556)或将您的代码添加到问题中,我将对其进行修改。