#'NoneType' object has no attribute 'bot'?

1 messages · Page 1 of 1 (latest)

simple furnace
#

I'm using self.bot in a sub command in a cog, and apparently self has no attribute bot?

Full error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/disnake/ext/commands/slash_core.py", line 355, in invoke
    await call_param_func(self.callback, inter, self.cog, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/disnake/ext/commands/params.py", line 1022, in call_param_func
    return await maybe_coroutine(safe_call, function, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/disnake/utils.py", line 599, in maybe_coroutine
    return await value
  File "/Users/user/Desktop/Projects/Python/Discord/AIO-Bot/cogs/reminders.py", line 112, in set
    bot = self.bot
AttributeError: 'NoneType' object has no attribute 'bot'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1353, in process_application_commands
    await app_command.invoke(interaction)
  File "/usr/local/lib/python3.10/site-packages/disnake/ext/commands/slash_core.py", line 724, in invoke
    await self.invoke_children(inter)
  File "/usr/local/lib/python3.10/site-packages/disnake/ext/commands/slash_core.py", line 713, in invoke_children
    await subcmd.invoke(inter, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/disnake/ext/commands/slash_core.py", line 364, in invoke
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'bot'
#

I'm guessing the error is actually something else but for some reason the wrong message is displayed?

hollow junco
#

Well you do have two set functions.

#

And two remove functions

#

Probably not related, but it's a problem nonethless

simple furnace
#

They’re sub commands for different slash commands tho and I think it has worked previously?

#

But I may try to change that

hollow junco
#

Doesn't matter if they're sub commands or not. That's just for registration. you shouldn't have functions that have the same name.

simple furnace
#

Ok ye that makes sense I’ll change that when I work on it again?

#

Do u have any idea what might be causing the error?

unique zinc
#

Fix the mentioned issue first

simple furnace
#

Thanks, this issue has been solved. I have no idea why that was the error message displayed, but I guess this is what comes of naming two functions the same

#

One last thing, I know that the functions with the same name caused the error, but is there any way to have the commands the same name without causing this error

#

Like is there some parameter that I can use somewhere?

unique zinc
#

@something.<slash_>command(name=...)

#

And I think I know why you were getting that None has no attribute error

simple furnace
unique zinc
#

You wouldn't understand happythonk

simple furnace
#

fair enough lmao

unique zinc
#

TL;DR creating two methods with same name makes the former one forgotten by the class

#

And because methods are ✨ descriptors ✨ and a descriptor outside a class receives None instead of self, there

simple furnace
#

oh fancy

#

ok

#

Thanks for help