Hi! I have the following code in the pregame.py cog:
class PregameCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.utilities = self.bot.get_cog("UtilitiesCog")
@commands.command()
async def newgame(self, ctx):
...
if self.utilities.get_config_item('status') == 'on':
...
The utilities cog has this:
class UtilitiesCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
def get_config_item(self, key):
state = self.read_game_state()
return state[key]
I get this error:
...
if self.utilities.get_config_item('status') == 'on':
AttributeError: 'NoneType' object has no attribute 'get_config_item'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 347, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 950, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 187, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'get_config_item'
I don't know what's causing the error, and sometimes it doesn't happen. Sometimes it stops happening and works correctly when I edit one of the involved files (any kind of edit apparently? but not always?) then save and reload the cogs. But as soon as the bot is restarted, the error appears again. I will appreciate any help because I've spent an hour trying to figure out this one and I'm no further than in the beginning 😅
I'm using the 2.5.0rc5 version.