简体   繁体   English

Discord py 表情符号 URL 问题

[英]Discord py Emoji URL issue

Hi I'm currently experiencing some issues with getting the URL directly from an emoji to create an emoji (Example *e:Cat: namehere) it throws up no errors but doesn't do what its supposed to do which is get the url of the emoji and make it into an emoji嗨,我目前遇到一些问题,直接从表情符号获取 URL 以创建表情符号(例如 *e:Cat:namehere)它不会引发任何错误,但没有做它应该做的事情,即得到 url表情符号并将其变成表情符号

side note Union[discord.Emoji, discord.PartialEmoji] is what im having an issue with since im trying to get the url directly from the emoji with out this piece it works by doing (*e link name)旁注Union[discord.Emoji, discord.PartialEmoji]是我遇到的问题,因为我试图直接从表情符号中获取 url 而没有这块它可以通过做(*e链接名称)

@bot.command(aliases=['e'])
async def emoji(ctx, url: Union[discord.Emoji, discord.PartialEmoji], str, *, name):
    async with bot.ses.get(url) as r:
        try:
            if r.status in range (200, 299):
                img = BytesIO(await r.read())
                bytes = img.getvalue()
                emoji = await ctx.guild.create_custom_emoji(image=bytes, name=name)
                await ctx.send(f"ez pz heres ur emoji {emoji}")
            else:
                await ctx.send("ERROR WHAT DID YOU DO")
        except discord.HTTPException:
            await ctx.send(random.choice(joke))

In this case, url is a discord.Emoji and not actually a URL.在这种情况下, urldiscord.Emoji而实际上不是 URL。 What you should do is rename the parameter to emoji , and then at the top of your function put url = emoji.url你应该做的是将参数重命名为emoji ,然后在 function 的顶部放置url = emoji.url

If you need the URL as a PNG, you can do emoji.url_as('png')如果你需要 URL 作为 PNG,你可以做emoji.url_as('png')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM