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)


基础教程推荐
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 筛选NumPy数组 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01