【问题标题】:Discord bot just repeats the same message over and overDiscord 机器人只是一遍又一遍地重复相同的消息
【发布时间】:2020-08-06 05:39:26
【问题描述】:

我是 python 和一般编码的新手。我创建了这个机器人 MIDA,每当我发送一条消息让机器人响应它时,都会用不同的命令输出回复,然后一遍又一遍地发送该消息。

代码:

@client.event
async def on_member_join(member):
    for channel in member.server.channels:
        if str(channel) == "conversing":
            await client.send_message(f"""Welcome Consul {member.mention}""")

@client.event
async def on_message(message):
    id = client.get_guild(enter id here)
    channels = ("bot-requests")
    if str(message.channel) in channels:
        if message.content.find("MIDA hello there"):
            await message.channel.send("GENERAL KENOBI!")

@client.event
async def on_message(message):
    id = client.get_guild(enter id here)
    channels = ("bot-requests")
    if message.content.find("MIDA users"):
        await message.channel.send(f"""# number of members {id.member_count}""")

@client.event
async def on_message(message):
    id = client.get_guild(enter id here)
    channels = ("bot-requests")
    if message.content.find("MIDA Skyrim sucks"):
        await message.channel.send("The voice of Todd Howard echos in the past: You're on thin ice kiddo.")

【问题讨论】:

    标签: python bots discord


    【解决方案1】:

    可能是由于同一个函数的三种不同定义。另外,我建议您使用built-in commands,从长远来看会容易得多。

    【讨论】:

      【解决方案2】:

      在on_message中你需要检查消息是否是bot发送的,否则它会一直响应它自己的消息。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-12-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多