成员加入上的不一致Bot

2024-04-20 10:55:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要一个discord机器人的帮助

import discord
client = discord.Client()

@client.event
async def on_member_join(member):
    print('new member')
    role = discord.utils.get(member.guild.roles, name='Unnamend')
    await member.add_roles(role)
    print(str(member.roles))

这是我的代码,如果我加入,我没有收到消息或角色,有人知道我如何修复它吗


Tags: importclienteventnewasyncondef机器人
1条回答
网友
1楼 · 发布于 2024-04-20 10:55:19

看来意图不见了

确保为您的应用程序打开Discord Developer Portal中所有必需的选项

要在代码中实现它们,可以使用以下命令:

intents = discord.Intents.all() # Imports all the Intents
client = commands.Bot(command_prefix="YourPrefix", intents=intents)

或者在您的情况下:

intents = discord.Intents.all() # Imports all the Intents
client = discord.Client(intents=intents)

相关问题 更多 >