mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Prohibit zero-length prefixes in [p]set [server]prefix (#6013)
Co-authored-by: Kreusada Ignad Amredes <67752638+Kreusada@users.noreply.github.com>
This commit is contained in:
parent
9345b691b3
commit
9dc7462d0f
@ -117,6 +117,7 @@ _ = i18n.Translator("Core", __file__)
|
|||||||
TokenConverter = commands.get_dict_converter(delims=[" ", ",", ";"])
|
TokenConverter = commands.get_dict_converter(delims=[" ", ",", ";"])
|
||||||
|
|
||||||
MAX_PREFIX_LENGTH = 25
|
MAX_PREFIX_LENGTH = 25
|
||||||
|
MINIMUM_PREFIX_LENGTH = 1
|
||||||
|
|
||||||
|
|
||||||
class CoreLogic:
|
class CoreLogic:
|
||||||
@ -4052,6 +4053,24 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
_("Prefixes cannot start with '/', as it conflicts with Discord's slash commands.")
|
_("Prefixes cannot start with '/', as it conflicts with Discord's slash commands.")
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
if any(len(x) < MINIMUM_PREFIX_LENGTH for x in prefixes):
|
||||||
|
await ctx.send(
|
||||||
|
_(
|
||||||
|
"Warning: A prefix is below the recommended length (1 character).\n"
|
||||||
|
"Do you want to continue?"
|
||||||
|
)
|
||||||
|
+ " (yes/no)"
|
||||||
|
)
|
||||||
|
pred = MessagePredicate.yes_or_no(ctx)
|
||||||
|
try:
|
||||||
|
await self.bot.wait_for("message", check=pred, timeout=30)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
await ctx.send(_("Response timed out."))
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
if pred.result is False:
|
||||||
|
await ctx.send(_("Cancelled."))
|
||||||
|
return
|
||||||
if any(len(x) > MAX_PREFIX_LENGTH for x in prefixes):
|
if any(len(x) > MAX_PREFIX_LENGTH for x in prefixes):
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_(
|
_(
|
||||||
@ -4111,6 +4130,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
_("Prefixes cannot start with '/', as it conflicts with Discord's slash commands.")
|
_("Prefixes cannot start with '/', as it conflicts with Discord's slash commands.")
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
if any(len(x) < MINIMUM_PREFIX_LENGTH for x in prefixes):
|
||||||
|
await ctx.send(_("You cannot have a prefix shorter than 1 character."))
|
||||||
|
return
|
||||||
if any(len(x) > MAX_PREFIX_LENGTH for x in prefixes):
|
if any(len(x) > MAX_PREFIX_LENGTH for x in prefixes):
|
||||||
await ctx.send(_("You cannot have a prefix longer than 25 characters."))
|
await ctx.send(_("You cannot have a prefix longer than 25 characters."))
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user