Discord py 嵌入不工作,但在它之前直接发送频道

问题描述 投票:0回答:0

我正在用 python 开发一个不和谐的机器人;我正在尝试更新我的 ctx.send 以返回嵌入与简单消息。我的代码如下。有趣的是,ctx.send 有效,但我的机器人没有直接在其下方发送嵌入并且没有显示任何错误。请注意这是在齿轮内。

另外 - main.check_if_username_used(username) 函数和代码工作。机器人发送第一个 await.ctx.send 消息,但随后立即使其下方的嵌入失败。定义用户名后,我还尝试使用标题和描述变量进行此操作;同样的事情。

 @commands.command()
    async def register(self, ctx, name):
        """registers a user"""
        discord_id = ctx.author.id
        username = name

            
        # Check if discord_id already exists 
        # If yes, update username
        # If not, register the new user 
        if main.check_if_username_used(username) > 0:
            await ctx.send("That username already exists.  Please select another.")
            title = "***CAUTION***"
            description = "That username already exists.  Please select another."
            embed = discord.Embed(title = f'{title}', description = f'{description}', color = discord.Color.red)
            await ctx.send(embed=embed)

我已经尝试了许多不同的方法,包括简单地将文本放入嵌入与 F 字符串中,我尝试将嵌入创建为辅助函数,但由于它不起作用,我将其直接放入命令中。

python discord.py embed
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.