robertwayne / dpymenus

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

Rate limited #50

Closed StormWalkerOnGitHub closed 3 years ago

StormWalkerOnGitHub commented 3 years ago

WARNING:discord.http:We are being rate limited. Retrying in 0.08 seconds. Handled under the bucket "782672909961134080:None:/channels/{channel_id}/messages/{message_id}/reactions"

This has been popping up when clicking the cancel menu reaction. Was curious what I can do with the library to prevent this library from getting me rate limited.

Bot has no previous history of being rate limited before the menu library was implemented into the code.

My code for my cog below is as follows currently: import discord import typing

from discord.ext import commands from dpymenus import Page, PaginatedMenu `

Help Command

class Help(commands.Cog): def init(self, client): self.client = client

@commands.command(name='help', aliases=['h', 'commands'], description='The help Command!')
async def help(self, ctx):

    waspNest_Icon = 'https://static-cdn.jtvnw.net/jtv_user_pictures/cb749623-989b-4814-9836-897e9ad7d38a-profile_image-300x300.png'

    page1 = Page(title='Help Command', description='The "help" command home page')
    page1.set_thumbnail (url = waspNest_Icon)
    page1.add_field(name=f'help', value='Brings you to this useful page!')
    page1.set_footer(text='Bot is created and maintained by St0rmWalker#9328')

    page2 = Page(title='Page 2', description='Second page test!')
    page2.set_thumbnail (url = waspNest_Icon)
    page2.add_field(name='Example C', value='Example D')

    page3 = Page(title='Page 3', description='Third page test!')
    page3.set_thumbnail (url = waspNest_Icon)
    page3.add_field(name='Example E', value='Example F')

    menu = PaginatedMenu(ctx)
    menu.add_pages([page1, page2, page3])
    await menu.open()

`

robertwayne commented 3 years ago

Discord.py handles this internally with rate limit buckets, so you're never hitting the Discord servers -- which means no need to worry about it in general. The reason this happens is because buttons are being added just slightly faster than the limit. Generally this should only appear if you're adding more than 4 or 5 buttons to a menu in quick succession, so a bit weird it got you for the default PaginatedMenu.

That said, because this has been a recurring question, this will be addressed in the next version with a higher default (and user adjustable) delay to alleviate these issues.