#How to change Bot's profile picture

1 messages · Page 1 of 1 (latest)

weak mason
#

Goal of the command is to change my bot's profile picture. I'm confused because without the self argument, I get an exception about missing the argument 'self'. When I add 'self', it says self is not defined. What argument am I missing?

With self argument

@bot.slash_command(guild_ids=[servers])
async def force_pfp(ctx):
    
    with open('/path/to/picture', 'rb') as image:
        await discord.ClientUser.edit(self, avatar=image)
         
    await ctx.respond('PFP changed')

without self argument

@bot.slash_command(guild_ids=[servers])
async def force_pfp(ctx):
    
    with open('/path/to/picture', 'rb') as image:
        await discord.ClientUser.edit(avatar=image)
         
    await ctx.respond('PFP changed')

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: ClientUser.edit() missing 1 required positional argument: 'self'

little brook
#

bot.edit(avatar=file)

weak mason
#

I'm confused. Am I still supposed to use ClientUser? ClientUser.bot also doesn't seem to have edit

hot mantle
#

You don't use discord.ClientUser

#

That's the class

#

You use the object

#

bot.user should give you that

#

@weak mason i hope this helps

weak mason
#

Thanks! I figured out what I was doing wrong.

Extra
I forgot to also add .read() which actually turns the image to bytes

@bot.slash_command(guild_ids=[servers])
async def change_pfp(ctx):
    
    await ctx.defer()

    with open('/path/to/picture', 'rb') as image:
        await discord.ClientUser.edit(bot.user, avatar=image.read())
         
    await ctx.respond('PFP changed')