Skip to content

Commit 479df30

Browse files
Remove unused ValidDiscordServerInvite converter (#3307)
1 parent 6236a4c commit 479df30

File tree

1 file changed

+0
-39
lines changed

1 file changed

+0
-39
lines changed

bot/converters.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
from discord.utils import snowflake_time
1414
from pydis_core.site_api import ResponseCodeError
1515
from pydis_core.utils import unqualify
16-
from pydis_core.utils.regex import DISCORD_INVITE
1716

1817
from bot import exts, instance as bot_instance
19-
from bot.constants import URLs
2018
from bot.errors import InvalidInfractionError
2119
from bot.exts.info.doc import _inventory_parser
2220
from bot.log import get_logger
@@ -31,42 +29,6 @@
3129
RE_USER_MENTION = re.compile(r"<@!?([0-9]+)>$")
3230

3331

34-
class ValidDiscordServerInvite(Converter):
35-
"""
36-
A converter that validates whether a given string is a valid Discord server invite.
37-
38-
Raises 'BadArgument' if:
39-
- The string is not a valid Discord server invite.
40-
- The string is valid, but is an invite for a group DM.
41-
- The string is valid, but is expired.
42-
43-
Returns a (partial) guild object if:
44-
- The string is a valid vanity
45-
- The string is a full invite URI
46-
- The string contains the invite code (the stuff after discord.gg/)
47-
48-
See the Discord API docs for documentation on the guild object:
49-
https://discord.com/developers/docs/resources/guild#guild-object
50-
"""
51-
52-
async def convert(self, ctx: Context, server_invite: str) -> dict:
53-
"""Check whether the string is a valid Discord server invite."""
54-
invite_code = DISCORD_INVITE.match(server_invite)
55-
if invite_code:
56-
response = await ctx.bot.http_session.get(
57-
f"{URLs.discord_invite_api}/{invite_code.group('invite')}"
58-
)
59-
if response.status != 404:
60-
invite_data = await response.json()
61-
return invite_data.get("guild")
62-
63-
id_converter = IDConverter()
64-
if id_converter._get_id_match(server_invite):
65-
raise BadArgument("Guild IDs are not supported, only invites.")
66-
67-
raise BadArgument("This does not appear to be a valid Discord server invite.")
68-
69-
7032
class Extension(Converter):
7133
"""
7234
Fully qualify the name of an extension and ensure it exists.
@@ -466,7 +428,6 @@ async def convert(self, ctx: Context, arg: str) -> dict | None:
466428

467429

468430
if t.TYPE_CHECKING:
469-
ValidDiscordServerInvite = dict
470431
ValidFilterListType = str
471432
Extension = str
472433
PackageName = str

0 commit comments

Comments
 (0)