繁体   English   中英

Discord 机器人只是一遍又一遍地重复相同的消息

[英]Discord bot just repeats the same message over and over

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

代码:

@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.")

在 on_message 中,您需要检查消息是否由机器人发送,否则它将继续响应自己的消息。

可能是由于同一个function的三个不同定义。 另外,我建议您使用内置命令,从长远来看会容易得多。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM