poshbotio / PoshBot

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

Starting new discord bot instance gives method not found: no ForEach in PSCustomObject #225

Open uxlapogi opened 3 years ago

uxlapogi commented 3 years ago

Expected Behavior

Bot instances starts without an error. :(

Current Behavior

PoshBot.psm1:6886: [System.Management.Automation.PSCustomObject] no method found \"ForEach\"

Possible Solution

This is my first time starting a poshbot instance. The bot is offline in the channel.

Steps to Reproduce (for bugs)

Used command flow:

Import-Module PoshBot

$botConfig = Get-PoshBotConfiguration -Path .\ValBotConfig.psd1 $backend = New-PoshBotDiscordBackend -Configuration $botConfig.BackendConfiguration

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

ValBotConfig.psd1

@{ ApprovalConfiguration = @{ Commands = @() ExpireMinutes = 30 } DisallowDMs = $False ModuleManifestsToLoad = @() LogDirectory = 'C:\ValBot' Name = 'ValBot' BotAdmins = @('xxx') AlternateCommandPrefixSeperators = @(':',',',';') CommandHistoryMaxLogSizeMB = 10 MiddlewareConfiguration = @{ PreReceive = @() PostReceive = @() PreExecute = @() PostResponse = @() PreResponse = @() PostExecute = @() } FormatEnumerationLimitOverride = -1 LogLevel = 'Verbose' SendCommandResponseToPrivate = @() ChannelRules = @{ IncludeCommands = @('*') Channel = 'valbot' ExcludeCommands = @() } ConfigurationDirectory = 'C:\ValBot' MaxLogsToKeep = 5 AddCommandReactions = $True CommandHistoryMaxLogsToKeep = 5 MaxLogSizeMB = 10 PluginDirectory = 'C:\ValBot' MuteUnknownCommand = $False PluginConfiguration = @{

} AlternateCommandPrefixes = @('valbot') CommandPrefix = '!' BackendConfiguration = @{ Name = 'DiscordBackend' Token = 'xxx' ClientId = 'xxx' GuildId = 'xxx' } PluginRepository = @('PSGallery') LogCommandHistory = $True }

Context

I'm trying to get a Discord Bot to control my Valheim dedicated server.

Your Environment

devblackops commented 3 years ago

@uxlapogi It looks like you're getting an error here when loading the Discord users. Can you change the LogLevel to Debug in your config and share that log output?

Please make sure to sanitize any sensitive info before sharing!

mechaming commented 3 years ago

I'm also having the same issue. Windows 10, powershell 5.1, powershell 7.0

I was able to get it working by upgrading powershell 7 to 7.1.2!