【发布时间】:2018-10-03 16:15:11
【问题描述】:
我决定为我的机器人的右舷模块重写我的代码。 当将星形反应以外的任何反应添加到帖子中然后将消息发布到右舷时,我遇到了问题。
它的运行方式是当只有一个星形表情符号添加到帖子中时,它将添加到右舷。
我不确定这是否是简单的迭代,但这是我正在使用的
async def on_reaction_add(self, reaction, member):
for guild in self.bot.guilds:
chan = get(guild.channels, name="starboard")
if chan:
for i in reaction.message.reactions:
if i.emoji == '⭐':
return
if reaction.message.author == member:
return
if reaction.count < 1:
return
embed=discord.Embed(color=0xff8000, description=reaction.message.content)
embed.set_author(name=reaction.message.author.name, icon_url=reaction.message.author.avatar_url)
if len(reaction.message.attachments) > 0:
embed.set_image(url=reaction.message.attachments[0]["url"])
embed.set_footer(text=f"Posted in {reaction.message.channel.name}")
embed.timestamp = dt.datetime.utcnow()
await chan.send("New Star!", embed=embed)
【问题讨论】:
标签: python-3.x iteration discord.py discord.py-rewrite