Giter Site home page Giter Site logo

kookiiestudios / palcon-discord Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 3.0 112 KB

A Python-based Discord bot for PalWorld server administration via RCON

License: MIT License

Python 89.24% Shell 5.40% Batchfile 5.36%
palworld palworld-dedicated-server palworld-tool discord discord-bot discord-py palworld-rcon rcon-client

palcon-discord's Issues

[BUG] Unable to parse player info for player

Describe the bug
A clear and concise description of what the bug is.

When i use the command "/online" every time is 0 Players Online, and in the console this error is showing:
"Unable to parse player info for player"

2024-02-02 13:29:59,574 - client - INFO - Setting up RCON connection
2024-02-02 13:29:59,579 - client - DEBUG - Fetching online players
2024-02-02 13:29:59,702 - client - ERROR - Unable to parse player info for player: ['Order', '24XXXXXXX5681']

Desktop (please complete the following information):
**- OS: Windows 2019

Bot on integration page? Need help pls

How can I add the bot to the integration page in discord? So that only certain commands are available to normal users? It would be nice if someone could explain this to me.

[Unable to fetch/send metadata of connected players: list index out of range]

Every so often in the discord server it will throw the error:
Unable to process your request

The console error:
2024-02-01 20:04:17,373 - client - INFO - Setting up RCON connection
2024-02-01 20:04:17,373 - client - DEBUG - Fetching online players
2024-02-01 20:04:17,417 - main - ERROR - Unable to fetch/send metadata of connected players: list index out of range

It does get a little annoying as we rely on this to work all the time, I love the thing you have made :)
I would at least like to know why this happens and if this can be fixed/When it will be fixed?

This was working before and I have not touched the configs, It just seems to happen from time to time.

ModuleNotFoundError: No module named 'tomllib'

After running ./setup.sh on ubuntu, ./start.sh fails with no module named tomllib venv or global.

ubuntu@ip-172-31-11-51:~/PalCON-Discord$ ./start.sh
This script will launch the program.

  1. Virtual Python Environment (recommended)
  2. Global Python Environment
  3. Quit
    Please select the environment to run the source code with: 2
    [INFO] You have selected: 2) Global Python Environment
    Traceback (most recent call last):
    File "/home/ubuntu/PalCON-Discord/main.py", line 7, in
    from client import fetch_config, Client
    File "/home/ubuntu/PalCON-Discord/client.py", line 1, in
    import tomllib
    ModuleNotFoundError: No module named 'tomllib'

Slash Interactions Should Not Timeout Before RCON Response

          > 2024-02-08 13:18:05,487 - client - DEBUG - Lines: [] [2024-02-08 13:18:05] [ERROR ] discord.app_commands.tree: Ignoring exception in command 'online' Traceback (most recent call last): File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 828, in _do_call return await self._callback(interaction, **params) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\PalCON-Discord\main.py", line 106, in online await interaction.response.send_message(embed=embed_message) File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\interactions.py", line 801, in send_message await adapter.create_interaction_response( File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async_.py", line 219, in request raise NotFound(response, data) discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

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

Traceback (most recent call last): File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1248, in _call await command._invoke_with_namespace(interaction, namespace) File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 853, in _invoke_with_namespace return await self._do_call(interaction, transformed_values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 846, in _do_call raise CommandInvokeError(self, e) from e discord.app_commands.errors.CommandInvokeError: Command 'online' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

I'm getting an error. I've reinstalled it a few times. I'll try again on another computer for now. Maybe the Python is twisted.

For this one, I'm guessing it's timing out - I'll have to double check the timeout duration for RCON side, to make sure that it's kept within 3 seconds

Although the proper way to handle this is probably to use the .defer() method to allow the slash command to not time out before the internal RCON client gives a response to the Discord bot

Originally posted by @KOOKIIEStudios in #6 (comment)

Integer Error?

Hello, I am not sure what version of python you are using (I am using 3.12) but I got an error when passing the PORT to the Console client

raised an exception: TypeError: 'str' object cannot be interpreted as an integer

It's odd because it's set as an int in the env file.

As a work around, I just cast the str to an int.

self.port: int = int(port)

Maybe I am missing something.

port=config["port"],

Thanks for the awesome work!

[SUGGESTION] Posts in the Discord Channel

Is there a way to make a message only visible to the admin?
E.g. "/save" the post will be displayed to all users in the Discord Channel that the world has been saved.

I saw with another bot "Palbot" that it is only displayed for the person who executed the command. Not to mention that only certain messages were visible to all users.

Maybe it's a stupid question, but I'm still new to the whole Discord thing^^.

[BUG] Received few bytes!

Describe the bug
A clear and concise description of what the bug is.

When i use the command "/announce" the first time it works, but the second time I get the error in the console:
"ERROR - Unable to make game announcement: Received few bytes!"

The first text was: "Um 20 Uhr ist der"
The second text was: "für 10min Offline"

The first text worked, the second didn't.

2024-02-03 19:41:33,509 - client - INFO - Setting up RCON connection
2024-02-03 19:41:33,513 - client - DEBUG - Broadcasting message to world
2024-02-03 19:41:33,643 - __main__ - ERROR - Unable to make game announcement: Received few bytes!

Desktop (please complete the following information):
**- OS: Windows 2019

Version: Latest Build** 88d0285

[BUG] ModuleNotFoundError: No module named 'discord'

You have selected A: Virtual Python Environment
Traceback (most recent call last):
File "C:\Users\MY COM\PycharmProjects\PalCON-Discord\main.py", line 3, in
import discord
ModuleNotFoundError: No module named 'discord'

The Python version is 3.11
i run start.bat, get the same error as above.
Is it a problem if I use a language other than English for config?

Sync Command Discussion

I was curious on your thoughts of using a normal command for this? (!sync) style

Or would you like something passed during the start of the bot?

Thanks

[BUG] Admin commands not checking perms properly

Describe the bug
initial report

To Reproduce
Steps to reproduce the behavior:

  1. Have a non-admin use any commands other than /info or /online
  2. Notice that they're somehow able to use them
    testing on our side

Expected behavior
Non-admins should not be allowed to use admin commands

Plausible explanations
The way this is currently handled is the following in line 5 of main.py:

from discord.ext.commands import has_permissions

which is then consumed as a decorator for admin commands like so:

@has_permissions(administrator=True)

Based on the latest API docs for Interactions (which slash commands fall under) from discord.py, the way to check for permissions is to use this instead:

@app_commands.checks.has_permissions(administrator=True)

Note that we already import app_commands in line 4 of main.py:

from discord import app_commands

This solution has been tested by the reporter of the bug. We'll just need to perform the refactoring to remote for this issue.
findings following investigation

[SUGGESTION] join/leave

Hello,

It's possible to add join /leave messages in game chat for players ?

It's good to keep track of who's joining and leaving .

Also to send messages from discord to ingame chat world be great, and pre defined messages to be send every set time , like sending discord link every 1h, stuff like that .

And thanks for making this

[BUG] after patch 1.5 (palworld)

This script will now launch the program.
Please select the environment to run the source code with:
A: Virtual Python Environment (Default)
B: Global Python Environment
What is your choice [A,B]?A
You have selected A: Virtual Python Environment
2024-02-29 15:44:03,628 - client - DEBUG - Fetching logger for client
2024-02-29 15:44:03,629 - client - INFO - Fetching configuration file
2024-02-29 15:44:03,630 - main - DEBUG - Fetching logger for main
2024-02-29 15:44:03,671 - client - INFO - Setting up RCON connection
2024-02-29 15:44:03,671 - client - DEBUG - Fetching online players
2024-02-29 15:44:05,711 - main - ERROR - Error updating bot status: [WinError 10061] No connection could be established because the target computer expressly refused it

[SUGGESTION] Allow starting server as subprocess via discord

image

My initial impression to their request is that this might be plausible via python launching a subprocess - not too sure about the details; warrants investigation.

We can offer support for those running via steamcmd, and account for path differences by having the user manually add the path into config.toml; the bash vs batch difference can be accounted for using sys.platform from the standard library (probably with some additional helper functions).

Of course first step is to test and see whether using subprocess for this even works in win11/ubuntu (iirc palworld server via steamcmd doesn't require sudo, so we shouldn't be running into permission issues

The bigger picture for this is that aside from having a command to start the game server, it would naturally also need to run san checks for whether there is already a game server running, which means that we will need to implement monitoring for the subprocess to make sure that any game servers are already shutdown. This would probably open the floodgates for a restart command, where palcon schedules a shutdown, and then restarts the server after.

(Also reminder to whoever works on this to write san checks for whether the server start script is accessible when the command is called - in case config.toml not properly configured)

Cannot start bot

Hi,

Im on Windows when i start the bot no matter what option do i chose it just closes itself?

It has to run in the same machine as the server?

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.