Reputation: 81
So I have ran into a problem where I get this error. In the documentation there is clearly a message attribute.
Here is my code (a part of it which doesn't work):
@client.command()
async def reg(message, oktaz):
message.message.delete()
How could I fix this?
Upvotes: 1
Views: 1731
Reputation: 4743
ctx
is the first parameter of every command. So you should change your code to this:
@client.command()
async def reg(ctx, message, oktaz):
await ctx.message.delete()
Upvotes: 0
Reputation: 471
Your code worked for me, except it wouldn't delete unless I added await
on message delete (message.message.delete()
-> await message.message.delete()
), but even if I didn't add await
, I wouldn't get that type of error. The only problem why it wouldn't delete the message for you is because you didn't add await. You shouldn't be getting an error saying "type object 'Context' has no attribute 'message'" if I'm correct. Are you sure you're not getting the error from a different part of the code that isn't the one you gave? Or maybe while pputting the code in stackoverflow you removed the part where the error is coming from in the reg command? Or you made a change but never saved?
@client.command()
async def reg(message, oktaz):
await message.message.delete()
Upvotes: 1