首页 > 解决方案 > 为什么我的从 url 更改 webhook 头像的程序在 discord.py 中不起作用

问题描述

我在 discord.py 中的程序不起作用。我想制作!rules将创建 webhook 并发送带有规则的消息的命令。我在尝试设置头像时遇到问题。

async def rules(self,ctx,*args):
        respone=f"This is rules of **{ctx.guild.name}** server."
        numba=1
        for o in args:
            respone=respone+f"```{numba}. {o}```"
            numba=numba+1
        web=await ctx.channel.create_webhook(name='Rules')
        await web.edit(avatar_url="https://cdn.pixabay.com/photo/2021/01/19/03/56/girl-5929995_960_720.jpg")
        await web.send(respone)
        await ctx.author.send(f"Because command will be deleted, here's backup of it: \n`{ctx.message.content}`")
        await ctx.message.delete()

有人可以帮忙吗?我尝试使用这些图像:

https://cdn.pixabay.com/photo/2021/02/08/16/03/dinosaur-5995333_960_720.png (png)
https://cdn.discordapp.com/avatars/731900211428851744/03adc5705993b66267666ff67be84d34.webp (my discord avatar, webp)
https://cdn.pixabay.com/photo/2021/01/19/03/56/girl-5929995_960_720.jpg (jpg)

谢谢你。

标签: pythondiscorddiscord.py

解决方案


尝试等待 web.edit(avatar=ctx.author.avatar_url)


推荐阅读