我用 on_member_join
事件制作了一个自动角色分配系统,它一直工作到现在,现在它不向成员发送消息,也不分配角色。请帮忙:
@bot.event
async def on_member_join(member):
Role1 = discord.utils.get(member.guild.roles, id = 723244173779533925)
await member.add_roles(Role1)
Role2 = discord.utils.get(member.guild.roles, id = 723244271628582962)
await member.add_roles(Role2)
Role3 = discord.utils.get(member.guild.roles, id = 723563998393663499)
await member.add_roles(Role3)
await member.send('Hi, welcome to my server! In 30 seconds i will give you verified role, please **read rules** in that time.')
await asyncio.sleep(30)
verifiedRole = discord.utils.get(member.guild.roles, id = 788393533874765855)
await member.add_roles(verifiedRole)
await member.send('I given you the verified role, and you have access to the rest of the guild.')
答案 0 :(得分:1)
听起来你需要意图。
您需要在 bot
的定义上方添加此代码:
intents = discord.Intents.default()
intents.members = True
现在,将 intents=intents
参数添加到意图位下方的机器人初始化中:
intents = discord.Intents.default()
intents.members = True
# If you have commands.Bot, add `intents = intents` in the parentheses:
bot = commands.Bot(your_options_here,intents = intents)
# If you have discord.Client(), add `intents = intents` into the parentheses:
bot = discord.Client(intents = intents)
确保在 developer portal 中启用成员意图。 您可以详细了解意图here。