【发布时间】:2019-07-27 07:20:42
【问题描述】:
我在下面得到了这个脚本,它将消息发送到所有具有称为“聊天频道”的频道的服务器,但问题是因为它要发送到每个名为“聊天频道”的频道,服务器本身具有该频道所以机器人发送到你发送的服务器中的频道,我也不想要,有什么办法解决这个问题?
(In short: The bot should send message to all servers that have the bot and a channel called 'Chat-channel' but not send to that server the message was sent from even thought it has a channel called 'Chat-channel')
Chnls=[]
@bot.event
async def on_message(message):
if message.author != bot.user:
for chan in Chnls:
ch=get(bot.get_all_channels(),id=chan)
if ch.name=='Chat-channel' and ch.id in Chnls:
await ch.send(message.content)
【问题讨论】:
-
为什么不让用户进入您将发布到的频道,并与您的机器人用户交叉引用以排除这些频道
-
不明白,我该怎么做?
标签: python python-3.x discord.py discord.py-rewrite