如何停止运行不和谐的机器人进程(python) [英] How to stop running discord bot process (python)

查看:35
本文介绍了如何停止运行不和谐的机器人进程(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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆