Cog-Creators / Cog-Creators/Red-DiscordBot

[Alias] Command Parsing with JSON `{}` data

Open
#6,524 0 comments 0 reactions 0 assignees View on GitHub
Category: Cogs - Alias Status: Accepted Type: Bug
Dominant language
Python
Stars
5.7k
Forks
2.5k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

When attempting to add an alias with JSON content, the Python exceptions out because it messes with the JSON parameters.

```
alias global edit test say JSON Data: {"data": "How are you?", "content": "{0}"}
```

### Output
> Error in command 'alias global edit'. Check your console or logs for details.

### Log
```
[2025-02-11 23:46:06] [ERROR] red: Exception in command 'alias global edit'

Traceback (most recent call last):

File "/data/venv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped

ret = await coro(*args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/data/venv/lib/python3.11/site-packages/redbot/cogs/alias/alias.py", line 383, in _edit_global_alias

if await self._aliases.edit_alias(ctx, alias_name, command, global_=True):

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/data/venv/lib/python3.11/site-packages/redbot/cogs/alias/alias_entry.py", line 235, in edit_alias

command = self.format_command_for_alias(command)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/data/venv/lib/python3.11/site-packages/redbot/cogs/alias/alias_entry.py", line 206, in format_command_for_alias

command = command.format(*(f"{{{i}}}" for i in range(-low, high + low + 1)))

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

KeyError: '"data"'
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.