从discord.utils导入You can wait for a reaction to a specific message if you need to. This is handy for times like this, where you maybe want to wait for a reaction then keep doing your coroutine. I will write the below assuming you're using the most up-to-date rewrite. You can find the documentation for all this here:from discord.utils import getfrom discord.ext.commands import Cog, commandlistener = Cog.listenerthumbs_up = "\N{THUMBS UP SIGN}"def react_check(user, msg, emoji): def check(reaction, usr): return usr==user and reaction.message.id==msg.id and reaction.emoji==emoji return checkclass MyCog(Cog): def __init__(self, bot): self.bot = bot @listener() async def on_member_join(self, member): guildName = user.guild.name embed = discord.Embed(colour=discord.Color(random.randint(0x000000, 0xFFFFFF))) embed.title = "Welcome to {} {}!".format(guildName, user) embed.description = "Head over to <#443133907102203912> to have a read up on our rules. Once you have read them please reaction to this post with a :thumbsup:" embed.set_image(url='') msg = await user.send(embed=embed) await self.bot.wait_for('reaction_add', check=react_check(user, msg, thumbs_up)) role = get(user.guild.roles, name="Members") await user.add_roles(role)然后在您的主程序中,您需要显示一行Then in your main bot, you need a line that saysfrom mycog import MyCogbot.add_cog(MyCog(bot)) 这篇关于在对帖子做出反应时出现添加角色的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 18:23