简体   繁体   English

我怎样才能让退货正常工作? 不和谐.py

[英]how can i let return properly work? discord.py

@commands.Cog.listener()
 async def on_message(self, message):
        if message.channel.topic == None:
            pass
        else:
            if "[SSbot deactivation]" in message.channel.topic:
                print(message.channel.name)
                return
            else:
                pass

even though i've got return , still running.即使我已经return ,仍在运行。 can anyone help?.任何人都可以帮忙吗?

The return statement only stops the current function - if the function is called again, it will still run. return语句只停止当前函数 - 如果再次调用该函数,它仍然会运行。 The on_message function is called every time a message is sent, so that return statement will not stop the bot.每次发送消息时都会调用on_message函数,因此 return 语句不会停止机器人。 If you are trying to end the python script, you could use the exit() command (note that python IDLE shows a prompt to confirm).如果您尝试结束 python 脚本,您可以使用exit()命令(请注意,python IDLE 会显示确认提示)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM