【问题标题】:How to Change my Profile Picture With a Discord bot(Python)?如何使用 Discord 机器人(Python)更改我的个人资料图片?
【发布时间】:2021-08-13 02:40:42
【问题描述】:

我想用 Python 创建一个机器人 哪个改变了我的头像 我的意思是我想在 Discord With bot 中更改我的个人资料图片 请帮帮我

【问题讨论】:

    标签: python discord bots


    【解决方案1】:

    我找到了解决方案。

    import discord
    
    client = discord.Client()
    
    token = 'TOKEN HERE'
    pfp_path = "path/to/file.png"
    
    fp = open(pfp_path, 'rb')
    pfp = fp.read()
    
    @client.event
    async def on_ready():
        await client.user.edit(avatar=pfp)
        
    client.run(token)
    

    我创建了这个解决方案:https://gist.github.com/MrLotU/b11d868243062ba9210f4994c1158d43

    【讨论】:

    • 您应该关闭文件或使用上下文管理器顺便说一句
    • 这是完全错误的,这是针对不和谐机器人的。但我想更改我的用户头像
    猜你喜欢
    • 2019-09-14
    • 2021-01-26
    • 2018-01-16
    • 2021-09-23
    • 2019-04-29
    • 2017-09-30
    • 2019-05-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多