我需要使用 discord.py rewrite 更改 python discord bot 的头像(头像)
I need to change a python discord bot's avatar (profile picture) using discord.py rewrite
这是我目前更改头像的代码:
with open("image.png", "rb") as file:
await discord.ClientUser.edit(self=, avatar=file)
首先,我什至不知道这是否是您更改机器人头像的方式。如果是这样,我不知道我需要在 self=
之后放什么。我试着阅读文档并询问人们如何去做,但我没有找到解决这个问题的方法。任何帮助将不胜感激。
这是我定义客户的方式:client = commands.Bot(command_prefix='.')
您可以使用ClientUser
更改头像,但您需要调用class。你不能做 discord.ClientUser.edit
。换头像需要bytes like object。所以,这应该有效:
with open('image.png', 'rb') as image:
await client.user.edit(avatar=image)
上述回答思路正确,但遗漏了一些东西。
这是怎么做的:
with open('image.png', 'rb') as image:
await client.user.edit(avatar=image.read())
这是我目前更改头像的代码:
with open("image.png", "rb") as file:
await discord.ClientUser.edit(self=, avatar=file)
首先,我什至不知道这是否是您更改机器人头像的方式。如果是这样,我不知道我需要在 self=
之后放什么。我试着阅读文档并询问人们如何去做,但我没有找到解决这个问题的方法。任何帮助将不胜感激。
这是我定义客户的方式:client = commands.Bot(command_prefix='.')
您可以使用ClientUser
更改头像,但您需要调用class。你不能做 discord.ClientUser.edit
。换头像需要bytes like object。所以,这应该有效:
with open('image.png', 'rb') as image:
await client.user.edit(avatar=image)
上述回答思路正确,但遗漏了一些东西。
这是怎么做的:
with open('image.png', 'rb') as image:
await client.user.edit(avatar=image.read())