【问题标题】:getting 'NoneType' object has no attribute 'send'获取“NoneType”对象没有“发送”属性
【发布时间】:2021-08-11 12:38:22
【问题描述】:

获取“NoneType”对象没有“发送”属性我该怎么办?这个错误让我头疼

async def message(ctx, *, mymsg):
    role = discord.utils.get(ctx.guild.roles, name="زاجل")
    await ctx.message.delete()
    await ctx.send(f'انتظر قليلا وسيتم نشر  رسالتك <a:Aonigif2:780891217549328425> {ctx.message.author.mention}', delete_after=5)
    await asyncio.sleep(3)
    await ctx.message.author.remove_roles(role)
    user = client.get_user(732195349661351987)
    await user.send(f'{mymsg}')```

【问题讨论】:

  • userNone。这意味着client.get_user(...) 正在返回None。也许那个用户不存在?

标签: python python-3.x discord discord.py bots


【解决方案1】:

您需要Members Intent

您必须启用它here。选择您想要的应用程序 -> 选择 Bot -> SERVER MEMBERS INTENT,然后确保它旁边显示为蓝色。然后单击保存更改。由于您正在开发您的机器人,您可能还希望启用 Presence Intent 以节省您以后的时间。

然后您必须像这样编辑您的机器人变量:

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix=".", intents=intents)

【讨论】:

  • @OtakuXD 确保用户与您共享服务器
猜你喜欢
  • 2021-11-12
  • 1970-01-01
  • 2021-08-19
  • 2019-12-12
  • 2021-12-10
  • 2013-11-06
  • 1970-01-01
  • 2022-07-21
  • 1970-01-01
相关资源
最近更新 更多