In the past there was only one context that I could subclass and add my own properties. But now there is ApplicationContext and Interaction. I want to be able to access my db instance from both by doing interaction.db and ctx.db respectively. First is there a way to do this without making 2 subclasses that look exactly the same besides the name. Second for ApplicationContext I need to subclass the bot and use this code
async def get_application_context(self, interaction: Interaction, cls=None) -> discord.ApplicationContext:
return await super().get_application_context(interaction, cls=cls or AdvContext)
But I am not seeing an equivalent function to override for interaction.
This is my full file right now
class AdvContext(discord.ApplicationContext):
@property
def prespond(self, *args, **kwargs):
return PrettyRespond(self)
class AdvInteraction(discord.Interaction):
@property
def prespond(self, *args, **kwargs):
return PrettyRespond(self)
setattr(discord.ApplicationContext, "db", database)
setattr(discord.Interaction, "db", database)
class SurveyWolf(discord.Bot):
async def get_application_context(self, interaction: Interaction, cls=None) -> discord.ApplicationContext:
return await super().get_application_context(interaction, cls=cls or AdvContext)