【发布时间】:2019-04-15 18:34:22
【问题描述】:
我正在尝试制作一个机器人,当会员说出某些关键字时将其重定向到某个频道,但如果他们已经在#commands 中,我不希望该机器人告诉他们进入#commands。如何让机器人忽略#commands 中的所有消息?
【问题讨论】:
标签: python-3.x discord discord.py
我正在尝试制作一个机器人,当会员说出某些关键字时将其重定向到某个频道,但如果他们已经在#commands 中,我不希望该机器人告诉他们进入#commands。如何让机器人忽略#commands 中的所有消息?
【问题讨论】:
标签: python-3.x discord discord.py
如果message.channel.id 等于#commands 的ID,只需在on_message 事件中添加一个检查即可返回。
@client.event
async def on_message(message):
#Ignore messages sent in channel with id 1234567890 (#commands channel)
if message.channel.id == 1234567890:
return
#Ignore messages sent by the bot
if message.author == client.user:
return
【讨论】: