rfalias / project_zomboid_bot

Discord bot for managing your PZ server.
18 stars 7 forks source link

Windows path issues #10

Closed AWL-Gaming closed 2 years ago

AWL-Gaming commented 2 years ago

Hello, The bot is throwing exceptions because of invalid file paths. The syntax looks like Unix and didn't work with plain Windows relative paths pointing to the bot.

Ignoring exception in command pzsetaccess:
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "Z:\Bots\project_zomboid_bot\pzbot.py", line 189, in pzsetaccess
    c_run = await rcon_command(ctx, [f"setaccesslevel", f"{user}", f"{access_level}"])
  File "Z:\Bots\project_zomboid_bot\pzbot.py", line 149, in rcon_command
    p = Popen(c, stdout=subprocess.PIPE)
  File "C:\Python310\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python310\lib\subprocess.py", line 1435, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [WinError 2] The system cannot find the file specified
rfalias commented 2 years ago

I have not tested this on windows, but any non relative paths will need to be converted to windows format, as well as adding the rcon commands relevant to windows. It should work fine once those are rectified. If you need help, reopen the issue. Make sure rcon command is in the same dir as the bot python scripts