poshbotio / PoshBot

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

Recently having issues with 403 forbidden and 50001 Missing access errors. #222

Open Kickbut101 opened 3 years ago

Kickbut101 commented 3 years ago

Expected Behavior

The bot should read and receive commands and fulfill any requests coming in

Current Behavior

Bot doesn't even start up. Gets 403 errors talking about 50001 missing access. After a while of this it just quits.

Possible Solution

I would suspect some of the changes discord implemented recently have broken the script. Discord has changed bots/api access in last month or so

Steps to Reproduce (for bugs)

Try connecting to discord with poshbot? I don't know specifically. This only started happening in last week. Prior to that everything was swimming.

Context

Your Environment

Kickbut101 commented 3 years ago

Heres a snip of the log; \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (429) Too Many Requests.: {\n \"global\": false, \n \"message\": \"You are being rate limited.\", \n \"retry_after\": 8605\n}\n","Data":{}} {"DataTime":"2020-10-09 21:14:32Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Warning","LogLevel":"Info","Message":"{\n \"global\": false, \n \"message\": \"You are being rate limited.\", \n \"retry_after\": 8605\n}\n","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:41Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [2] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (429) Too Many Requests.: {\n \"global\": false, \n \"message\": \"You are being rate limited.\", \n \"retry_after\": 8513\n}\n","Data":{}} {"DataTime":"2020-10-09 21:14:42Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Warning","LogLevel":"Info","Message":"{\n \"global\": false, \n \"message\": \"You are being rate limited.\", \n \"retry_after\": 8513\n}\n","Data":{}} {"DataTime":"2020-10-09 21:14:51Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Normal","LogLevel":"Debug","Message":"Attempted [3] of [3]","Data":{}} {"DataTime":"2020-10-09 21:14:51Z","Class":"DiscordBackend","Method":"LoadUsers","Severity":"Normal","LogLevel":"Debug","Message":"[] users returned","Data":{}} {"DataTime":"2020-10-09 21:14:51Z","Class":"Bot","Method":"Start","Severity":"Error","LogLevel":"Info","Message":"Method invocation failed because [System.Management.Automation.PSCustomObject] does not contain a method named \u0027ForEach\u0027.","Data":{"CommandName":null,"Message":"Method invocation failed because [System.Management.Automation.PSCustomObject] does not contain a method named \u0027ForEach\u0027.","TargetObject":"ForEach","Position":"At C:\\Program Files\\WindowsPowerShell\\Modules\\PoshBot\\0.12.0\\PoshBot.psm1:6831 char:9\r\n+ $allUsers.ForEach({\r\n+ ~~~~~~~~~~~~~~~~~~~","CategoryInfo":"InvalidOperation: (ForEach:String) [], RuntimeException","FullyQualifiedErrorId":"MethodNotFound"}} {"DataTime":"2020-10-09 21:14:51Z","Class":"Bot","Method":"Disconnect","Severity":"Normal","LogLevel":"Verbose","Message":"Disconnecting from backend chat network","Data":{}} {"DataTime":"2020-10-09 21:14:51Z","Class":"DiscordConnection","Method":"Disconnect","Severity":"Normal","LogLevel":"Info","Message":"Closing websocket","Data":{}} {"DataTime":"2020-10-09 21:14:51Z","Class":"DiscordConnection","Method":"Disconnect","Severity":"Normal","LogLevel":"Info","Message":"Stopping receive job [1]","Data":{}} {"DataTime":"2020-10-09 21:14:51Z","Class":"Bot","Method":"Disconnect","Severity":"Normal","LogLevel":"Verbose","Message":"Disconnecting from backend chat network","Data":{}} {"DataTime":"2020-10-09 21:14:51Z","Class":"DiscordConnection","Method":"Disconnect","Severity":"Normal","LogLevel":"Info","Message":"Closing websocket","Data":{}} {"DataTime":"2020-10-09 21:14:51Z","Class":"DiscordConnection","Method":"Disconnect","Severity":"Normal","LogLevel":"Info","Message":"Stopping receive job [1]","Data":{}}

devblackops commented 3 years ago

@Kickbut101 Thanks for reporting this. You mentioned Discord changed things in the API. Can you point me to what changed?

Kickbut101 commented 3 years ago

@Kickbut101 Thanks for reporting this. You mentioned Discord changed things in the API. Can you point me to what changed?

I assume it's something in here; https://discord.com/developers/docs/change-log#api-and-gateway-v8

Maybe the gateway? I'm just spitballing

EDIT I thought maybe I was just being stupid or had broken something else. So I just built a fresh .14 version today, made a new config file, and sent it off, and got an almost identical error. I'll list the end of the log file here;

{"DataTime":"2020-10-11 17:20:29Z","Class":"Scheduler","Method":"LoadState","Severity":"Normal","LogLevel":"Verbose","Message":"Loading scheduler state from storage","Data":{}} {"DataTime":"2020-10-11 17:20:29Z","Class":"StorageProvider","Method":"GetConfig","Severity":"Warning","LogLevel":"Info","Message":"Configuration file [C:\\Users\\Administrator\\.poshbot\\schedules.psd1] not found","Data":{}} {"DataTime":"2020-10-11 17:20:33Z","Class":"Bot","Method":"Start","Severity":"Normal","LogLevel":"Info","Message":"Start your engines","Data":{}} {"DataTime":"2020-10-11 17:20:33Z","Class":"Bot","Method":"Start","Severity":"Normal","LogLevel":"Info","Message":"Setting global FormatEnumerationLimit to [-1]","Data":{}} {"DataTime":"2020-10-11 17:20:33Z","Class":"Bot","Method":"Connect","Severity":"Normal","LogLevel":"Verbose","Message":"Connecting to backend chat network","Data":{}} {"DataTime":"2020-10-11 17:20:33Z","Class":"DiscordBackend","Method":"Connect","Severity":"Normal","LogLevel":"Info","Message":"Connecting to backend","Data":{}} {"DataTime":"2020-10-11 17:20:33Z","Class":"DiscordBackend","Method":"Connect","Severity":"Normal","LogLevel":"Info","Message":"Listening for the following message types. All others will be ignored","Data":["CHANNEL_CREATE","CHANNEL_DELETE","CHANNEL_UPDATE","MESSAGE_CREATE","MESSAGE_DELETE","MESSAGE_UPDATE","MESSAGE_REACTION_ADD","MESSAGE_REACTION_REMOVE","PRESENSE_UPDATE"]} {"DataTime":"2020-10-11 17:20:34Z","Class":"DiscordConnection","Method":"StartReceiveJob","Severity":"Normal","LogLevel":"Info","Message":"Started websocket receive job [1","Data":{}} {"DataTime":"2020-10-11 17:20:34Z","Class":"DiscordBackend","Method":"GetBotIdentity","Severity":"Normal","LogLevel":"Verbose","Message":"Bot identity is [630302282939891731]","Data":{}} {"DataTime":"2020-10-11 17:20:34Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-11 17:20:34Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-11 17:20:34Z","Class":"DiscordBackend","Method":"_SendDiscordMsg","Severity":"Error","LogLevel":"Info","Message":"Unable to query URI \u0027https://discordapp.com/api/guilds/383060918625370112/members?limit=1000\u0027: The remote server returned an error: (403) Forbidden.: {\"message\": \"Missing Access\", \"code\": 50001}","Data":{}} {"DataTime":"2020-10-11 17:20:34Z","Class":"Bot","Method":"Start","Severity":"Error","LogLevel":"Info","Message":"Method invocation failed because [System.Management.Automation.PSCustomObject] does not contain a method named \u0027ForEach\u0027.","Data":{"CommandName":null,"Message":"Method invocation failed because [System.Management.Automation.PSCustomObject] does not contain a method named \u0027ForEach\u0027.","TargetObject":"ForEach","Position":"At C:\\Program Files\\WindowsPowerShell\\Modules\\PoshBot\\0.14.0\\PoshBot.psm1:6886 char:9\r\n+ $allUsers.ForEach({\r\n+ ~~~~~~~~~~~~~~~~~~~","CategoryInfo":"InvalidOperation: (ForEach:String) [], RuntimeException","FullyQualifiedErrorId":"MethodNotFound"}} {"DataTime":"2020-10-11 17:20:34Z","Class":"Bot","Method":"Disconnect","Severity":"Normal","LogLevel":"Verbose","Message":"Disconnecting from backend chat network","Data":{}} {"DataTime":"2020-10-11 17:20:34Z","Class":"DiscordConnection","Method":"Disconnect","Severity":"Normal","LogLevel":"Info","Message":"Closing websocket","Data":{}}

Kickbut101 commented 3 years ago

@devblackops

I'm sorry to have wasted your time. I think I found it. And maybe this is worth posting a PSA now for discord. But it seems in the last week or so (I had my last "successful" commands on 10-4-20) Discord has changed some access for bots.

They now require you to check specific gateway permissions through the bot admin interface on their developer portal. image

These were not checked by default, and upon checking them it seems to have allowed my bot to function again.

devblackops commented 3 years ago

That's good to know @Kickbut101. Thanks. I'll do some testing on my end to repro and update the docs.