我如何在这里定义CTX? [英] How can i define ctx here?

查看:32
本文介绍了我如何在这里定义CTX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@client.event
async def on_message(message):
    if client.user.mentioned_in(message):
        embed = discord.Embed(title='Im here boss', description='Prefix: `n!help`', color=discord.Colour.from_rgb(249, 35, 142))
        embed.set_image(url='https://i.pinimg.com/originals/fe/1d/60/fe1d606ca0bcaf954a78cae3ed9c628b.gif')
        embed.set_footer(icon_url = ctx.author.avatar_url, text = f'Brought here by {ctx.author.name}')
        await message.channel.send(embed=embed)

如果我在异步定义项中添加CTX,它会显示一个错误,它没有定义,而且在页脚中也没有定义。我如何在此定义CTX?

推荐答案

不要使用ctx.author.*使用message.author.*,但是如果您确实想要获取Context(ctx),请使用以下命令:

ctx = await client.get_context(message)

这篇关于我如何在这里定义CTX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆