[英]discord.py - How do I send a message to multiple channels?
So... I wanted to make an code so it send an message to an specific channel所以......我想制作一个代码,以便向特定频道发送消息
I want so it send this message in chat #logs
and #mod-log
我想要它在聊天#logs
和#mod-log
发送此消息
Heres the code:代码如下:
channel = discord.utils.get(user.server.channels, name=['logs', 'mod-log'])
embed = discord.Embed(name="MEMBER_WARNED", description="------------------------------------------------------", color=0xffaa00)
embed.set_author(name="MEMBER_WARNED:\nMember Warned")
embed.add_field(name="Warned by: ", value="{}".format(author.mention), inline=False)
client = bot
await client.send_message(channel, embed=embed)
You have to send a separate message to each channel:您必须向每个频道发送单独的消息:
channels = [channel for channel in user.server.channels if channel.name in ['logs', 'mod-log']]
embed = discord.Embed(name="MEMBER_WARNED", description="------------------------------------------------------", color=0xffaa00)
embed.set_author(name="MEMBER_WARNED:\nMember Warned")
embed.add_field(name="Warned by: ", value="{}".format(author.mention), inline=False)
for channel in channels:
await bot.send_message(channel, embed=embed)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.