Add Pterodactyl cog #19

Merged
cswimr merged 139 commits from pterodactyl into main 2024-03-02 00:07:42 -05:00
2 changed files with 11 additions and 5 deletions
Showing only changes of commit 4979e44b7c - Show all commits

View file

@ -127,11 +127,11 @@ achivement messages: ^\[\d{2}:\d{2}:\d{2} INFO\]: (.*) has (made the advancement
The cog uses a tellraw command to send messages to Minecraft from Discord. To change this, use the `[p]pterodactyl config chat command` command. The JSON format Minecraft uses for this is very janky sometimes, if you need help with changing the command, you can join my [Discord server](https://discord.gg/eMUMe77Yb8).
Required placeholders:
Available placeholders:
- `.%U` - replaced with display name
- `.%M` - replaced with message contents
- `.%C` - replaced with top role color (hex)
- `.$U` - replaced with display name
- `.$M` - replaced with message contents
- `.$C` - replaced with top role color (hex)
Default:
```json

View file

@ -83,7 +83,13 @@ class Pterodactyl(commands.Cog):
async def get_chat_command(self, username: str, message: str, color: discord.Color) -> str:
command: str = await config.chat_command()
command = command.replace(".$U", username).replace(".$M", message).replace(".$C", str(color))
placeholders = {
"U": username,
"M": message,
"C": str(color)
}
for key, value in placeholders.items():
command = command.replace('$.' + key, value)
return command
@commands.Cog.listener()