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

@@ -3536,6 +3536,11 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
**Arguments:**
- `<prefixes...>` - The prefixes the bot will respond to globally.
"""
if any(prefix.startswith("/") for prefix in prefixes):
await ctx.send(
_("Prefixes cannot start with '/', as it conflicts with Discord's slash commands.")
)
return
if any(len(x) > MAX_PREFIX_LENGTH for x in prefixes):
await ctx.send(
_(
@@ -3584,6 +3589,11 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
await ctx.bot.set_prefixes(guild=ctx.guild, prefixes=[])
await ctx.send(_("Server prefixes have been reset."))
return
if any(prefix.startswith("/") for prefix in prefixes):
await ctx.send(
_("Prefixes cannot start with '/', as it conflicts with Discord's slash commands.")
)
return
if any(len(x) > MAX_PREFIX_LENGTH for x in prefixes):
await ctx.send(_("You cannot have a prefix longer than 25 characters."))
return