K
K
kutu33ov2021-07-02 13:57:24
Python
kutu33ov, 2021-07-02 13:57:24

Error 'NoneType' object has no attribute 'mention'. It worked before, how can I fix it?

The whole code is very long, so I throw a piece in which the error is. (I can throw the whole thing if needed)

if attempt >= age_min and attempt < age_max:
          
          
          administration = discord.utils.get(
            message.guild.roles, name = '[Administration]'
            )
          channelin = self.client.get_channel(818241897624764417)
          mention = message.author.mention

          await msg.add_reaction("✅")
          message_react = await message.channel.send(
            f'Отлично! Сейчас я вас перенаправлю на администрацию сервера..\nОжидайте..')
          # time.sleep(1)
          # await message.author.add_roles(role_new)
          # await message.author.remove_roles(role_verify)

          await message_react.add_reaction("")
          dot = await message.channel.send('`.`')
          await channelin.send(
            f'{mention} проверку возраста прошёл ✅ \n{administration.mention}, направляю его в <#819306461641179197>\nЖдите..\n**input age**: ' + str(attempt))


Mistake:
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\volva\Desktop\botTest\cogs\welcome.py", line 125, in on_message
    f'{mention} проверку возраста прошёл ✅ \n{administration.mention}, направляю его в <#819306461641179197>\nЖдите..\n**input age**: ' + str(attempt))
AttributeError: 'NoneType' object has no attribute 'mention'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Mokhovikov, 2021-07-11
@mohovoy

your mention is empty, that's why it writes NoneType
Try this:

if attempt >= age_min and attempt < age_max:
  administration = discord.utils.get(
    message.guild.roles, name = '[Administration]'
    )
  channelin = self.client.get_channel(818241897624764417)

  await msg.add_reaction("✅")
  message_react = await message.channel.send(f'Отлично! Сейчас я вас перенаправлю на администрацию сервера..\nОжидайте..')

  await message_react.add_reaction("")
  dot = await message.channel.send('`.`')
  await channelin.send(f'{message.author.mention} проверку возраста прошёл ✅ \n{administration.mention}, направляю его в <#819306461641179197>\nЖдите..\n**input age**: ' + str(attempt))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question