diff options
author | 2023-07-05 18:52:20 +0300 | |
---|---|---|
committer | 2023-07-05 18:52:20 +0300 | |
commit | f8638757d93e88e4279d178a6f460eb0264059ba (patch) | |
tree | ae97b58329a4f607e979d5deae17bcdf3f3ab4e6 | |
parent | Bump emoji from 2.5.1 to 2.6.0 (#2659) (diff) |
Allow arbitrary strings when adding invite filters
If the given content isn't in the discord.gg/<invite> pattern, it will instead take it as the invite code itself as long as it doesn't contain spaces.
-rw-r--r-- | bot/exts/filtering/_filters/invite.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bot/exts/filtering/_filters/invite.py b/bot/exts/filtering/_filters/invite.py index 799a302b9..d3a2621f0 100644 --- a/bot/exts/filtering/_filters/invite.py +++ b/bot/exts/filtering/_filters/invite.py @@ -1,3 +1,5 @@ +import re + from discord import NotFound from discord.ext.commands import BadArgument from pydis_core.utils.regex import DISCORD_INVITE @@ -33,8 +35,12 @@ class InviteFilter(Filter): """ match = DISCORD_INVITE.fullmatch(content) if not match or not match.group("invite"): - raise BadArgument(f"`{content}` is not a valid Discord invite.") - invite_code = match.group("invite") + if not re.fullmatch(r"\S+", content): + raise BadArgument(f"`{content}` is not a valid Discord invite.") + invite_code = content + else: + invite_code = match.group("invite") + try: invite = await bot.instance.fetch_invite(invite_code) except NotFound: |