Prevent / being used in bot or server prefixes (#5693)

* Update `[p]set prefix`/`[p]set serverprefix`

* Update cli

* style

* update __main__

* style

* improve checks

* Raise in Red.set_prefixes, update responses

* uniform responses

* Fixes

* Keep generator variable names consistent across files
This commit is contained in:
Kreusada Tanfala
2022-06-29 00:19:20 +01:00
committed by GitHub
parent febc503df1
commit ae80e62a13
4 changed files with 24 additions and 0 deletions

View File

@@ -45,6 +45,10 @@ class PrefixManager:
prefixes = prefixes or []
if not isinstance(prefixes, list) and not all(isinstance(pfx, str) for pfx in prefixes):
raise TypeError("Prefixes must be a list of strings")
if any(prefix.startswith("/") for prefix in prefixes):
raise ValueError(
"Prefixes cannot start with '/', as it conflicts with Discord's slash commands."
)
prefixes = sorted(prefixes, reverse=True)
if gid is None:
if not prefixes: