poshbotio / PoshBot

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

PoshBot Powershell Gallery \r\n+ #235

Closed cbrookins closed 1 year ago

cbrookins commented 3 years ago

When installed from Powershell Gallery receive error related to formatting on Start-Poshbot command.

Expected Behavior

Poshbot should start

Current Behavior

Powershell throws and error about a missing method for the file PoshBot.psm1. It singles out a line that I believe is due to the "\r\n+" included in the line. It seems to be related to formatting of the file as that actual text does not exist in the file.

"$allUsers.ForEach({\r\n+"

Possible Solution

Steps to Reproduce (for bugs)

  1. Install-Module PoshBot
  2. Run sample code
Import-Module PoshBot
$pbc = New-PoshBotConfiguration
$pbc.BotAdmins = @('<YOUR USERNAME>')

$backendConfig = @{
    Name     = 'DiscordBackend'
    Token    = '<TOKEN>'
    ClientId = '<CLIENT ID>'
    GuildId  = '<SERVER ID>'
}
$backend = New-PoshBotDiscordBackend -Configuration $backendConfig
$bot = New-PoshBotInstance -Configuration $pbc -Backend $backend
$bot | Start-PoshBot -Verbose

Context

Set up a simple bot with Discord to send a message on a schedule

Your Environment

devblackops commented 2 years ago

Thanks for the report @theRealc2c2. I noticed that you're running Windows PowerShell 5.1. I'm curious, have you tried running this in PowerShell Core (6+)? This errors seems to point to this where we wrap the .foreach() method onto a new line.

cbrookins commented 2 years ago

@devblackops I have not tried that, but I will test it out.