所以,我正在为我所在的服务器制作一个机器人,当你加入它时,它会给你一个未经验证的角色。所有者已与 Carl-Bot 设置了验证反应,我想知道如何让我的机器人在用户验证时删除未验证的角色?
我的代码:
@client.event
async def on_member_join(member):
try:
role = discord.utils.get(member.guild.roles, name="Unverified")
await member.add_roles(role)
print(f"{member} has joined")
verify = member.guild.get_channel(772263419210235916)
rules = member.guild.get_channel(772995392521895937)
channel = client.get_channel(772583213797212211)
embed=discord.Embed(title="Welcome to Delight Stuidos!",
description=f"{member.mention} has joined! \nDon't forget to read the {rules.mention}, and react with the purple star in {verify.mention}!\n Enjoy your stay ^^",
color = discord.Colour.orange())
embed.set_thumbnail(
url=member.avatar_url
)
await channel.send(embed=embed)
e = discord.Embed(title="Welcome to DS!",
description=f"""Be sure read the {rules.mention}\nand to verify with the purple heart in {verify.mention}!
If you have any questions, feel free to DM the mods and/or owner of the server!""",
color=discord.Colour.orange())
await member.send(embed=e)
except Exception as e:
print(e)
谢谢!
答案 0 :(得分:0)
一个简单的方法可能是使用验证,它为作者提供角色并删除未验证的角色
@client.command()
async def verify(ctx):
member = ctx.author
role_remove = discord.utils.get(member.guild.roles, name="Unverified")
await member.remove_roles(role_remove)
role_add = discord.utils.get(member.guild.roles, name="Verified")
await member.add_roles(role_add)
await ctx.send(f'Thanks, {member} for verification! You will now have access to the rest of our server.', delete_after=3)