robertwayne / dpymenus

Simplified menus for discord.py developers.
https://dpymenus.com/
MIT License
26 stars 4 forks source link

ButtonMenu timeout not working (v1.3) #33

Closed RaymondLWong closed 3 years ago

RaymondLWong commented 3 years ago

Whenever I create a ButtonMenu, it seems like it doesn't time out? I try to create a second menu and I see this:

INFO:root:Duplicate session in channel [x] for user [y].

Other users can create their own first menu and encounter the same error. Here's roughly the code I use:

async def create_menu(context: Context):
  def get_page() -> Page:
    current_page = Page(title='test')

    current_page.on_next(update_data)
    current_page.buttons(['⏪', '⏩'])

    return current_page

  async def update_data(menu: ButtonMenu):
    await menu.output.edit(embed=get_page().as_safe_embed())

  button_menu = ButtonMenu(context) \
      .add_pages([get_page()]) \
      .set_timeout(5) \
      .show_command_message() \
      .persist_on_close()
  await button_menu.open()

@bot.command()
async def test_menus(context: Context):
  await create_menu(context)

Edit: Seems like manually closing the menu mitigates this, so I'll use this as a workaround for now:

async def update_data(menu: ButtonMenu):
  if menu.button_pressed(stop_symbol):
    return await menu.close()
robertwayne commented 3 years ago

Thanks for reporting this. This should be fixed in v1.3.1, which is on PyPi now. You can re-open this if you encounter more issues! :)