Skip to content

Cannot connect to Discord backend #249

@AndrewJNet

Description

@AndrewJNet

Expected Behavior

Expect to connect to Discord without error

Current Behavior

Running Start-PoshBot will lead to the following 403 Forbidden errors and warnings when running the "Log into Discord with the bot token" section:

Write-Error:
Line |
16 | $bot | Start-PoshBot -Verbose
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| {"DataTime":"2023-08-25 03:36:15Z","Class":"DiscordConnection","Method":"ConnectGateway","Severity":"Error","LogLevel":"Info","Message":"Unable to determine Discord gateway URL","Data":{"CommandName":"Invoke-RestMethod","Message":"Response status code does not indicate success: 403 (Forbidden).","TargetObject":{"Version":{"Major":1,"Minor":1,"Build":-1,"Revision":-1,"MajorRevision":-1,"MinorRevision":-1},"VersionPolicy":0,"Content":null,"Method":{"Method":"GET"},"RequestUri":"https://discordapp.com/api/gateway/bot","Headers":[{"Key":"Authorization","Value":["Bot BOTTOKENREDACTED"]},{"Key":"User-Agent","Value":["Mozilla/5.0","(Windows NT 10.0; Microsoft Windows 10.0.22621; en-US)","PowerShell/7.3.6"]}],"Properties":[],"Options":[]},"Position":"At C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.13.0\PoshBot.psm1:7439 char:33\r\n+ … tewayInfo = Invoke-RestMethod -Uri 'https://discordapp.com/api/gatewa …\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~","CategoryInfo":"InvalidOperation: (Method: GET, Reques…PowerShell/7.3.6\r\n}:HttpRequestMessage) [Invoke-RestMethod], HttpResponseException","FullyQualifiedErrorId":"WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"}}

WARNING: {"DataTime":"2023-08-25 03:36:16Z","Class":"DiscordConnection","Method":"ReadReceiveJob","Severity":"Warning","LogLevel":"Info","Message":"Receive job state is [Failed]. Attempting to reconnect...","Data":null}

Possible Solution

Unsure. I am still troubleshooting.

Steps to Reproduce (for bugs)

Run the following:

Import-Module PoshBot
$pbc = New-PoshBotConfiguration
$pbc.BotAdmins = @('username')

$backendConfig = @{
Name = 'JohnsonBot'
Token = 'TOKEN'
ClientId = 'CLIENTID'
GuildId = 'GUILDID'
}

$backend = New-PoshBotDiscordBackend -Configuration $backendConfig

$bot = New-PoshBotInstance -Configuration $pbc -Backend $backend
$bot | Start-PoshBot -Verbose

Context

Moving PoshBot to a new computer and I'm running into this error. I've double-checked the ClientId and GuildId, as well as regenerated the token a number of times to make sure they were correct. Originally I had copied my configuration over from the old computer but after I experienced errors I tried starting from scratch. I'm a bit out of my element with this troubleshooting so I wanted to file an issue while I dug into it in case anyone is seeing a similar issue.

Your Environment

  • Module version used: PoshBot 0.13.0
  • Operating System and PowerShell version: Windows 11 22H2. Tested with PowerShell 7.3.6 and WindowsPowerShell 5.1.22621.1778

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions