如何为机器人创建和例外
How to create and exception for a bot
@bot.event
async def on_message(message):
if '!' in message.content:
return
if message.content.startswith(muti):
await asyncio.sleep(3)
await message.delete()
else:
await message.delete()
await message.channel.send(muti)
if message.author.bot:
return
我正在尝试创建一个例外,让我的机器人不会删除另一个机器人的消息,但我不知道该怎么做。我尝试使用 if message.author.(另一个机器人的 id 变量),但我不知道如何设置该变量。 message.author.bot 是为了让我的机器人忽略它自己的消息。
使用 member.bot
其中 returns 如果成员是机器人 documentation。
@bot.event
async def on_message(message):
if message.author.bot:
return
if '!' in message.content:
return
if message.content.startswith(muti):
await asyncio.sleep(3)
await message.delete()
else:
await message.delete()
await message.channel.send(muti)
if message.author.bot:
return
如果消息是由机器人发送的,这将不会执行下面的任何代码。
@bot.event
async def on_message(message):
if '!' in message.content:
return
if message.content.startswith(muti):
await asyncio.sleep(3)
await message.delete()
else:
await message.delete()
await message.channel.send(muti)
if message.author.bot:
return
我正在尝试创建一个例外,让我的机器人不会删除另一个机器人的消息,但我不知道该怎么做。我尝试使用 if message.author.(另一个机器人的 id 变量),但我不知道如何设置该变量。 message.author.bot 是为了让我的机器人忽略它自己的消息。
使用 member.bot
其中 returns 如果成员是机器人 documentation。
@bot.event
async def on_message(message):
if message.author.bot:
return
if '!' in message.content:
return
if message.content.startswith(muti):
await asyncio.sleep(3)
await message.delete()
else:
await message.delete()
await message.channel.send(muti)
if message.author.bot:
return
如果消息是由机器人发送的,这将不会执行下面的任何代码。