When I create a button and handle the callback or send a message and await a reaction in discord with my python bot, this seems to be limited in time. Sometimes after ~ 1hour, the bot doesn't register reactions anymore. For sure once I restart the bot, the connection is lost and it won't register the interaction anymore.
However, I have seen bots in discord that always react to a button, no matter how long ago that button was created. Is there a way to achieve this? Do I have to periodically "reconnect" the bot to the buttons it created?
Simple example:
class ButtonView(disnake.ui.View):
def __init__(self):
super().__init__(timeout=None)
@disnake.ui.button(label="Hi", style=ButtonStyle.red)
async def first_button(
self, button: disnake.ui.Button, interaction: disnake.MessageInteraction
):
await interaction.response.send_message("Button clicked.")
class Test(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.slash_command()
async def test(self, inter):
await inter.send("Button!", view=ButtonView())
-> In this example the bot won't react to the button click anymore after some time has passed or I restarted the bot.