【发布时间】:2021-08-20 21:21:02
【问题描述】:
我正在尝试让机器人向每个服务器的系统通道发送消息,但它总是最终将其发送到服务器上的顶部通道。到目前为止,这是我的代码:
@commands.command()
async def broadcast(self, ctx, *, text):
for server in self.client.guilds:
for system_channel in server.text_channels:
try:
await system_channel.send(text)
except Exception:
continue
else: break
编辑: 谢谢TheUntraceable!这是它的工作版本:
@commands.command()
async def broadcast(self, ctx, *, text):
for guild in self.client.guilds:
try:
await guild.system_channel.send(text)
except Exception:
continue
【问题讨论】:
标签: python python-3.x discord.py