Python Discord机器人只是一遍又一遍地重复相同的消息
我对python和一般的编码都是新手。我创建了这个bot MIDA,每当我发送一条消息让bot响应时,它都会用不同的命令输出进行回复,然后一遍又一遍地发送该消息 代码:Python Discord机器人只是一遍又一遍地重复相同的消息,python,bots,discord,Python,Bots,Discord,我对python和一般的编码都是新手。我创建了这个bot MIDA,每当我发送一条消息让bot响应时,它都会用不同的命令输出进行回复,然后一遍又一遍地发送该消息 代码: 在on_消息中,您需要检查消息是否由bot发送,否则它将继续响应自己的消息。在on_消息中,您需要检查消息是否由bot发送,否则它将继续响应自己的消息。可能是由于同一功能的三种不同定义。另外,我建议您使用,从长远来看,这将更容易。可能是因为同一函数有三种不同的定义。另外,我建议你使用,从长远来看会容易得多 @client.eve
在on_消息中,您需要检查消息是否由bot发送,否则它将继续响应自己的消息。在on_消息中,您需要检查消息是否由bot发送,否则它将继续响应自己的消息。可能是由于同一功能的三种不同定义。另外,我建议您使用,从长远来看,这将更容易。可能是因为同一函数有三种不同的定义。另外,我建议你使用,从长远来看会容易得多
@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.")