我使用的是discord
机器人,但是在安装pynacl
模块之后我无法调用构建成员。
这是代码。
@bot.command()
async def dm(ctx, who, * ,msg):
await ctx.guild.get_member_named(who).send()
这是关于代码的错误。
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
答案 0 :(得分:0)
您使用的是旧版本的discord.py。我希望你跑步
pip install discord -U
pip install discord.py -U
在终端中,因为它们是文档中的主要更改。
然后
@bot.command()
async def dm(ctx, user:discord.Member, *, msg):
await user.send(msg)