Reputation: 17
@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)
If i add ctx in the async def thing it shows an error and that it isnt defined and also in the footer it isnt defined. how do i define ctx in this thing here?
Upvotes: 1
Views: 118
Reputation: 15689
Instead of using ctx.author.*
use message.author.*
, though if you really want to get the Context
(ctx
) use the following:
ctx = await client.get_context(message)
Upvotes: 2
Reputation: 2017
You can use the get_context
method.
Wherever you need to get the ctx variable, add something like this:
ctx = await client.get_context(message)
You can also input a custom context as a second argument (cls=MyCustomCtx
)
Upvotes: 3