【问题标题】:Discord.py not excecutingDiscord.py 没有执行
【发布时间】:2022-11-22 22:53:18
【问题描述】:

这是我在 python 中的代码,每当我单击开始按钮时,它都会按照我使用 replit IDE 的方式自动停止。

import discord



class MyClient(discord.Client):
    async def on_ready(self):
        print(f'Logged on as {self.user}!')

    async def on_message(self, message):
        print(f'Message from {message.author}: {message.content}')

intents = discord.Intents.default()
intents.message_content = True

client = MyClient(intents=intents)


class MyClient(discord.Client):

  async def on_ready(self):
    print(f'Logged on as {self.user}!')

  async def on_message(self, message):
    print(f'Message from {message.author}: {message.content}')


intents = discord.Intents.default()
intents.message_content = True

client = MyClient(intents=intents)
import asyncio
async def client_start():
    await client.start('XYZ')

我真的不知道该尝试什么我希望应用程序自动启动,我不是 python 专家我的朋友问我这个,现在我请求你们帮助。

【问题讨论】:

    标签: python discord discord.py replit


    【解决方案1】:

    您需要启动一个服务器,否则它不会继续运行。

    尝试这个: https://github.com/sdrrv/Fate-Wielding-Bot/blob/master/keep_alive.py

    【讨论】:

    • 重要的是要注意,我认为 replit 不再允许机器人托管......很确定他们解决了这个问题。回到过去,您可以通过让uptimerobot.com ping 服务器来欺骗系统,然后 replit 会为您托管机器人。
    • 我现在把我的机器人放在我买的树莓派上。很酷的项目:)
    猜你喜欢
    • 2021-03-20
    • 2020-12-31
    • 2020-08-22
    • 1970-01-01
    • 2021-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多