簡體   English   中英

discord.py - 如何向多個頻道發送消息?

[英]discord.py - How do I send a message to multiple channels?

所以......我想制作一個代碼,以便向特定頻道發送消息

我想要它在聊天#logs#mod-log發送此消息

代碼如下:

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)

您必須向每個頻道發送單獨的消息:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM