egebilecen / PZServerDiscordBot

A Project Zomboid Discord Bot written in C# using Discord.NET to manage and execute commands on Project Zomboid Server.
GNU General Public License v3.0
70 stars 15 forks source link

Unable to use server commands #69

Closed FelipeCardona95 closed 1 year ago

FelipeCardona95 commented 1 year ago

Hi how are you?, I started using you tool yesterday on my server, everything seemed to be fine I set the channels where the bot is going to send msgs and also specified the token of my bot for the tool to use, Im able to use commands like image but none of this ever worked image for what I see in the server console is just this

LOG  : General     , 1677086148609> 263,408,217> [RZF] Schedule need to change from     dayTime  to     dayTime . No change is necessary.
LOG  : General     , 1677086234385> 263,493,993> command entered via server console (System.in): "servermsg "a""
LOG  : General     , 1677086234856> 263,494,464> Unknown command servermsg "a"
LOG  : General     , 1677086291522> 263,551,129> command entered via server console (System.in): "invisible "Yokaio""
ERROR: General     , 1677086291563> 263,551,170> java.lang.NullPointerException: Cannot read field "accessLevel" because "this.connection" is null
ERROR: General     , 1677086291563> 263,551,171>        at zombie.commands.serverCommands.InvisibleCommand.Command(InvisibleCommand.java:40)
ERROR: General     , 1677086291564> 263,551,171>        at zombie.commands.CommandBase.Execute(CommandBase.java:131)
ERROR: General     , 1677086291564> 263,551,171>        at zombie.network.GameServer.handleServerCommand(GameServer.java:1157)
ERROR: General     , 1677086291564> 263,551,171>        at zombie.network.GameServer.main(GameServer.java:884)
LOG  : General     , 1677086299264> 263,558,872> [RZF] Schedule detected is     dayTime
LOG  : General     , 1677086299265> 263,558,873> [RZF] Checking if preset       dayTime  is enabled
LOG  : General     , 1677086299265> 263,558,873> [RZF] Schedule need to change from     dayTime  to     dayTime . No change is necessary.

does the tool need to run with Admin privileges or something? I have also checked that my bot has the Privileged Gateway Intents, and they all checked image did I maybe missed something?

egebilecen commented 1 year ago

Hey, please share pzbot.log file. As for the error in console, I don’t know what’s the cause of it. — Bot doesn’t need to run privileged.

FelipeCardona95 commented 1 year ago

There it is, let me know if you need anything else, thank you

egebilecen commented 1 year ago

Hm, I couldn't find any errors related to those in the logs. Try to run the bot as administrator and see if it will fix it.

FelipeCardona95 commented 1 year ago

pzbot.log so tried running as admin and same result I also tried enabling the Discord option in my servers option to see if maybe that was the issue but nothing changed I see in the log these error arent these what we are looking for?

[22/02/2023 04:49:31 UTC] WebRequest.PostAsync() - Response status code is not 200. Status code: BadRequest | URL: https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/

---------------
Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: s
Stack trace: at System.IO.StringReader..ctor(String s)
   at Newtonsoft.Json.Linq.JToken.Parse(String json, JsonLoadSettings settings)
   at SteamWebAPI.<GetWorkshopItemDetails>d__3.MoveNext() in C:\Documents\Programming\C#\PZServerDiscordBot\src\Bot\Util\SteamWebAPI.cs:line 80
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Schedules.<>c__DisplayClass4_0.<<WorkshopItemUpdateChecker>b__0>d.MoveNext() in C:\Documents\Programming\C#\PZServerDiscordBot\src\Bot\Schedules\WorkshopItemUpdateChecker.cs:line 52
Date: 22/02/2023 04:49:31 UTC
Bot Version: v1.9.0
Exception occured in ScheduleItem callback function. ScheduleItem: WorkshopItemUpdateChecker
(THIS IS AN INNER EXCEPTION, NUMBER 1)
---------------
[22/02/2023 04:59:33 UTC] WebRequest.PostAsync() - Response status code is not 200. Status code: BadRequest | URL: https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/

---------------
Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: s
Stack trace: at System.IO.StringReader..ctor(String s)
   at Newtonsoft.Json.Linq.JToken.Parse(String json, JsonLoadSettings settings)
   at SteamWebAPI.<GetWorkshopItemDetails>d__3.MoveNext() in C:\Documents\Programming\C#\PZServerDiscordBot\src\Bot\Util\SteamWebAPI.cs:line 80
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Schedules.<>c__DisplayClass4_0.<<WorkshopItemUpdateChecker>b__0>d.MoveNext() in C:\Documents\Programming\C#\PZServerDiscordBot\src\Bot\Schedules\WorkshopItemUpdateChecker.cs:line 52
Date: 22/02/2023 04:59:33 UTC
Bot Version: v1.9.0
Exception occured in ScheduleItem callback function. ScheduleItem: WorkshopItemUpdateChecker
(THIS IS AN INNER EXCEPTION, NUMBER 1)

this specifically for the get ram command [22/02/2023 04:48:19 UTC] [BotCommands - get_ram_cpu] Caller: ⁦Yokai Sparda⁩#3430 [22/02/2023 04:49:31 UTC] WebRequest.PostAsync() - Response status code is not 200. Status code: BadRequest | URL: https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/

as for the command that works when I use the !stop_server command I have to send it twice cause the first time it gets in it doesnt seem to get recognized, why is that?

LOG  : General     , 1677169526930> 346,787,549> command entered via server console (System.in): "quit"
LOG  : General     , 1677169526975> 346,787,594> Unknown command quit
LOG  : General     , 1677169532293> 346,792,912> command entered via server console (System.in): "quit"
LOG  : Network     , 1677169532301> 346,792,920> DISCORD: get message on current channel
LOG  : Network     , 1677169532301> 346,792,920> DISCORD: send message = "!stop_server" for Yokai Sparda)
LOG  : General     , 1677169532301> 346,792,920> Player with nickname = 'Yokai Sparda' not found!
LOG  : General     , 1677169532301> 346,792,921> New message 'ChatMessage{chat=General, author='Yokai Sparda', text='!stop_server'}' was sent members of chat '0'
DEBUG: Multiplayer , 1677169532361> 346,792,981> QuitCommand.Command                 > cmd="quit" user="admin" role="32" unknown connection"
LOG  : Multiplayer , 1677169532362> 346,792,981>        java.base/java.lang.Thread.getStackTrace(Unknown Source)
LOG  : Multiplayer , 1677169532362> 346,792,981>        zombie.debug.DebugLogStream.printStackTrace(DebugLogStream.java:159)
LOG  : Multiplayer , 1677169532362> 346,792,982>        zombie.debug.DebugLogStream.printStackTrace(DebugLogStream.java:146)
LOG  : Multiplayer , 1677169532362> 346,792,982>        zombie.network.ServerMap.QueueQuit(ServerMap.java:91)
LOG  : Multiplayer , 1677169532363> 346,792,982>        zombie.commands.serverCommands.QuitCommand.Command(QuitCommand.java:29)
LOG  : Multiplayer , 1677169532363> 346,792,982>        zombie.commands.CommandBase.Execute(CommandBase.java:131)
LOG  : Multiplayer , 1677169532363> 346,792,982>        zombie.network.GameServer.handleServerCommand(GameServer.java:1157)
LOG  : Multiplayer , 1677169532363> 346,792,982>        zombie.network.GameServer.main(GameServer.java:884)
LOG  : General     , 1677169532364> 346,792,983> Quit
LOG  : General     , 1677169532522> 346,793,141> SaveAll took 65.5405 ms

so far those are the only things I can notice, theres anyway to enable more logging on the app to check the status of the commands?

egebilecen commented 1 year ago

Command used for ram / cpu information may need elevated permissions. Though based on other servers which are using the bot at the moment, it's not related to that. Did you setup admin account when you run the server for the first time? Because even general zomboid server commands are being recognized as unknown.

FelipeCardona95 commented 1 year ago

I think thats what Im missing I didnt do that, is this admin account just giving admin rights to 1 player? so in this case I should give myselft "Yokai Sparda" admin in the server?

FelipeCardona95 commented 1 year ago

so I gave admin and the character is admin ingame image image but !get_ram_cpu command still not works, neither it displays anything in console, besides giving admin dont I have to set which account is gonna be used to send the commands? sending msgs work and saving image image but things like !perk_info "Yokai Sparda" dont work tho it says author Server should it be Yokai Sparda?

egebilecen commented 1 year ago

I am not sure why ram/cpu doesn’t work. Might be related to the windows server. Perk info works without any issues. Use it as !perk_info “Character Name” , yeah. Character needs to be logged in, of course.