How to stop running discord bot process (python)(如何停止运行不和谐的机器人进程(python))
问题描述
我对这个 discord.py 很陌生.我刚刚做了一个 discord.py 机器人,它工作正常,但有时机器人会不断重复命令消息.我用谷歌搜索了这个问题,发现可能是为了一遍又一遍地运行脚本(比如在编辑或添加功能后保存并运行时).所以我想停止运行该进程,就像当我重新启动 Windows 时,机器人处于脱机状态(如果我在重新启动 Windows 后运行脚本,机器人会正常运行).请帮忙
Im new at this discord.py thing. I've just done a discord.py bot, it works ok, but sometimes the bot repeats constantly the command messages. I googled this problem and found out that maybe is for running the script over and over again (like when you save and run after edited or added functions). So I want to stop running the process, just like when I restart windows, the bot is offline (if I run the script after restarting windows, the bot acts normaly). Pls help
如果有人需要代码,我可以在这里粘贴.
If someone needs the code, I can paste it here then.
PD:我将机器人完全作为教程制作...
PD: I made the bot exact as a tutorial...
推荐答案
- 如果你添加我写在那里的代码(只有所有者可以使用)将关闭已经运行的机器人(写 /shutdown in不和谐服务器或任何你的前缀).
但是,在使用此代码保存机器人后,您可能需要重新启动 PC.
However, you may need a PC restart after saving the bot with this code.
@client.command()
@commands.is_owner()
async def shutdown(ctx):
await ctx.bot.logout()
- 所以每次如果你想编辑你的命令,你写/shutdown 并编辑它,然后你可以重新启动它.
我希望这对你有用并且我可以提供帮助.
I hope this works for you and that I could help.
这篇关于如何停止运行不和谐的机器人进程(python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何停止运行不和谐的机器人进程(python)


- 使用 Cython 将 Python 链接到共享库 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01