poshbotio / PoshBot

Powershell-based bot framework
MIT License
540 stars 108 forks source link

Discord backend locks up - Suspect rate limits #189

Open Kickbut101 opened 4 years ago

Kickbut101 commented 4 years ago

142 - Seems to be duplicate of this ticket!

Expected Behavior

I should be able to add-remove-update plugins at will and have the backend respect discords rate-limits so as not to lock up or lose connection to API.

Current Behavior

Currently something as simple as !Update-Plugin locks up the api with the last errors showing (verbose)

05:51:22Z","Class":"DiscordBackend","Method":"_WaitRateLimit","Severity":"Warning","LogLevel":"Info","Message":"Rate limit reached. Sleeping [0.250] milliseconds","Data":{}} WARNING: {"DataTime":"2019-11-13 05:51:22Z","Class":"DiscordBackend","Method":"_WaitRateLimit","Severity":"Warning","LogLevel":"Info","Message":"Rate limit reached. Sleeping [0.250] milliseconds","Data":{}} WARNING: {"DataTime":"2019-11-13 05:51:22Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Warning","LogLevel":"Info","Message":"{\n \"global\": false, \n \"message\": \"You are being rate limited.\", \n \"retry_after\": 138\n}\n","Data":{}}

Possible Solution

Steps to Reproduce (for bugs)

  1. Build 0.12.0 poshbot
  2. Connect bot and app in discord via https://poshbot.readthedocs.io/en/latest/guides/backends/setup-discord-backend/
  3. Follow this page to make test plugin https://poshbot.readthedocs.io/en/latest/tutorials/plugin-development/simple/
  4. Change the test plugin .psm1 file (I literally changed it from just write-output, to having an if statement to check if user input a username along with the !invoke-helloworld command).
  5. Try !update-plugin
  6. For me at this point it locks up, see the error log above.

Context

Just trying to build some bot in discord for personal use among myself and friends

Your Environment

Adamvg commented 4 years ago

Allow emojis to be turned off from PoshBotConfig.psd1 file ?

They can be turned off from the starting script: $pbc.AddCommandReactions = $false

devblackops commented 4 years ago

@Kickbut101 Can you expand on what you mean by "lock up"? You will see rate limit messages in the log but there should be no loss of functionality.

The Rate limit reached messages are normal for reactions as Discord has a very low rate limit on them. We act on the rate limit headers received from Discord and sleep accordingly.

Kickbut101 commented 4 years ago

@Kickbut101 Can you expand on what you mean by "lock up"? You will see rate limit messages in the log but there should be no loss of functionality.

The Rate limit reached messages are normal for reactions as Discord has a very low rate limit on them. We act on the rate limit headers received from Discord and sleep accordingly.

You bet!

My powershell ISE will lock up in "running" mode without allowing me to break the script which results in me having to "End Task" in task manager to get it to finally close/stop. In addition to this the bot becomes unresponsive and no longer listens or fulfills commands (like !status or !about or anything). I believe I also tried to run the script as a standalone script (running it just in a normal powershell console, outside the powershell ISE) and got same results.

This was a while ago so my memory on it is not quite as clear as it was. But I bet I can recreate it when I get home if you'd like.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

devblackops commented 4 years ago

Is this still an issue @Kickbut101?

Kickbut101 commented 4 years ago

I am unsure what causes it but the .12 build I made long ago does still die on it's own for some reason. It's probably not at all related to rate limits. But It will lock up and the powershell console will still be "running" but the bot status on discord goes to offline and no commands are accepted/run.

Again though, probably not rate limit related. More likely just a bad build on my part? Unsure. You can close this one.

Adamvg commented 4 years ago
    I get this too, but only when running commands - probably something in your module that is messing the bot up. Mine works fine for hours on end if I disable my scheduled command(s).

On Mon, Mar 30, 2020 at 12:46 AM +0100, "Kickbut101" notifications@github.com wrote:

I am unsure what causes it but the .12 build I made long ago does still die on it's own for some reason. It's probably not at all related to rate limits. But It will lock up and the powershell console will still be "running" but the bot status on discord goes to offline and no commands are accepted/run.

Again though, probably not rate limit related. More likely just a bad build on my part? Unsure. You can close this one.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.