|
13 | 13 | from discord.utils import snowflake_time
|
14 | 14 | from pydis_core.site_api import ResponseCodeError
|
15 | 15 | from pydis_core.utils import unqualify
|
16 |
| -from pydis_core.utils.regex import DISCORD_INVITE |
17 | 16 |
|
18 | 17 | from bot import exts, instance as bot_instance
|
19 |
| -from bot.constants import URLs |
20 | 18 | from bot.errors import InvalidInfractionError
|
21 | 19 | from bot.exts.info.doc import _inventory_parser
|
22 | 20 | from bot.log import get_logger
|
|
31 | 29 | RE_USER_MENTION = re.compile(r"<@!?([0-9]+)>$")
|
32 | 30 |
|
33 | 31 |
|
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 |
| - |
70 | 32 | class Extension(Converter):
|
71 | 33 | """
|
72 | 34 | 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:
|
466 | 428 |
|
467 | 429 |
|
468 | 430 | if t.TYPE_CHECKING:
|
469 |
| - ValidDiscordServerInvite = dict |
470 | 431 | ValidFilterListType = str
|
471 | 432 | Extension = str
|
472 | 433 | PackageName = str
|
|
0 commit comments