Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在discord.py中获取头像url_Python_Python 3.x_Discord_Discord.py - Fatal编程技术网

Python 如何在discord.py中获取头像url

Python 如何在discord.py中获取头像url,python,python-3.x,discord,discord.py,Python,Python 3.x,Discord,Discord.py,我正在尝试使用以下代码获取化身URL: import discord from discord.ext import commands client = commands.Bot(command_prefix=".") @client.command() async def avatar(ctx, *, member : discord.member): mava = member.avatar_url print(mava) client.run(TOKEN

我正在尝试使用以下代码获取化身URL:

import discord
from discord.ext import commands
client = commands.Bot(command_prefix=".")
@client.command()
async def avatar(ctx, *, member : discord.member):
    mava = member.avatar_url
    print(mava)
client.run(TOKEN)
我得到以下错误

discord.ext.commands.errors.MissingRequiredArgument:成员是缺少的必需参数


我已经挖了好几个小时,包括看教程,但我还没有找到解决办法。

需要做一些事情。您需要将
*,成员:discord.member)
更改为
成员:discord.member

@client.command()
异步def化身(ctx,成员:discord.member):#无asterik,大写discord.member
mava=member.avatar\u url
打印(mava)
我还建议使用
intent.members

总之,这意味着在执行命令时,您将执行以下操作:


.avatar@user或.avatar[user id]

在discord中调用命令时,实际上需要将成员作为参数传递,例如
.avatar@user
。您还需要启用
意向.成员
,否则
成员
参数将始终为
(查看我的其他答案)