KOOKIIEStudios / PalCON-Discord

A Python-based Discord bot for PalWorld server administration via RCON
MIT License
18 stars 3 forks source link

[SUGGESTION] Posts in the Discord Channel #14

Closed BloodDragon2580 closed 7 months ago

BloodDragon2580 commented 7 months ago

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^^.

Bratah123 commented 7 months ago

Yes, you can make messages only visible to the person who used the command, this is known as ephemeral messages, you can add it like so: await interaction.response.send_message(embed=embed_message, ephemeral=True) to this line

If you'd so like, we don't know if this is something we'd want to do for the project globally, but feel free to add it yourself!

BloodDragon2580 commented 7 months ago

Nice thx for the very fast Support.

BloodDragon2580 commented 7 months ago

After change this for "/save" Command this error is showing:

2024-02-03 00:20:24,785 - client - INFO - Setting up RCON connection
2024-02-03 00:20:24,786 - client - DEBUG - Saving world
[2024-02-03 00:20:26] [ERROR   ] discord.app_commands.tree: Ignoring exception in command 'save'
Traceback (most recent call last):
  File "C:\Users\Administrator\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 125, in save
    await interaction.response.send_message(embed=embed_message, ephemeral=true)
                                                                           ^^^^
NameError: name 'true' is not defined

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

Traceback (most recent call last):
  File "C:\Users\Administrator\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\Administrator\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\Administrator\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 'save' raised an exception: NameError: name 'true' is not defined
KOOKIIEStudios commented 7 months ago

True not true Brandon made a typo

KOOKIIEStudios commented 7 months ago

Python's booleans (i.e. true-or-false data types) are capitalised: True/False

That's why the Python interpreter is confused by true here - since there's no variable with the name true defined in the repo

BloodDragon2580 commented 7 months ago

It works wonderfully, many thanks to you.