kookiiestudios / palcon-discord Goto Github PK
View Code? Open in Web Editor NEWA Python-based Discord bot for PalWorld server administration via RCON
License: MIT License
A Python-based Discord bot for PalWorld server administration via RCON
License: MIT License
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
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
> 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)
If there's a language other than English
We found a problem that server info or connection name is not output and time out.
I don't know if it's a server problem or a bot coding problem. It seems to be a text encoding problem. Can you check it?
For your information, I use KOREAN.
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.
Line 33 in 1e597b9
Thanks for the awesome work!
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
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)
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^^.
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
To Reproduce
Steps to reproduce the behavior:
/info
or /online
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.
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?
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
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
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.
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.