Answer the question
In order to leave comments, you need to log in
How to remove "AttributeError: 'coroutine' object has no attribute 'content'" and "AttributeError: 'Message' object has no attribute 'user'" errors?
I write a bot on discord and it gives me this error:
File "C:\Users\nasty\Desktop\discord\test.py", line 21, in gdz
your_class = message_response.content
AttributeError: 'coroutine' object has no attribute ' content'
and this
File "C:\Users\nasty\Desktop\discord\test.py", line 20, in
message_response = client.wait_for('message', check=lambda m: m.user == ctx.user)
AttributeError: 'Message' object has no attribute 'user'
code itself:
client = commands.Bot( command_prefix = '!')
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.command( pass_context = True )
async def gdz(ctx):
await ctx.send('В каком вы классе? (8, 7, 9...)')
message_response = client.wait_for('message', check=lambda m: m.client == ctx.client)
your_class = message_response.content
await ctx.send('По какому предмету? (Геометрия, Физика, Химия...)')
message_response = client.wait_for('message')
your_pred = message_response.content
await ctx.send('Какой автор?(Пичугов, Вербицкая, Атанасян...)')
message_response = client.wait_for('message', check=lambda m: m.client == ctx.client)
your_auth = message_response.content
await ctx.send('Какой номер?(100, 1564, 290...)')
message_response = client.wait_for('message', check=lambda m: m.client == ctx.client)
your_num = message_response.content
if your_pred == 'Геометрия' and your_auth == 'Атанасян':
await ctx.send('https://gdz.ru/' + 'class-8' + '/' + 'geometria' + '/' + 'atanasyan-8' + '/' + your_num + '-task/')
elif your_auth == 'Пичугов':
await ctx.send('https://gdz.ru/' + 'class-' + your_class + '/' + 'russkii_yazik' + '/' + 'pichugov-praktika-' + your_class + '/' + your_num + '-nom/')
Answer the question
In order to leave comments, you need to log in
The class Message
has no attribute user
according to doc doc .
But there is an attributeauthor
A Member that sent the message. If channel is a private channel or the user has the left the guild, then it is a User instead.
client.wait_for
returns a string, and therefore content
it cannot have any. But in your case, the error is also that await is not specified before the coroutine, which is the method client.wait_for
message_response = await client.wait_for('message', check=lambda m: m.author== ctx.author)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question