|
45 | 45 |
|
46 | 46 | import discord.abc |
47 | 47 | from .permissions import PermissionOverwrite, Permissions |
48 | | -from .enums import ChannelType, StagePrivacyLevel, try_enum, VoiceRegion, VideoQualityMode |
| 48 | +from .enums import ChannelType, InviteTarget, StagePrivacyLevel, try_enum, VoiceRegion, VideoQualityMode |
49 | 49 | from .mixins import Hashable |
50 | 50 | from .object import Object |
51 | 51 | from . import utils |
|
55 | 55 | from .stage_instance import StageInstance |
56 | 56 | from .threads import Thread |
57 | 57 | from .iterators import ArchivedThreadIterator |
| 58 | +from .invite import Invite |
58 | 59 |
|
59 | 60 | __all__ = ( |
60 | 61 | 'TextChannel', |
@@ -1037,6 +1038,64 @@ async def edit(self, *, reason=None, **options): |
1037 | 1038 | # the payload will always be the proper channel payload |
1038 | 1039 | return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore |
1039 | 1040 |
|
| 1041 | + async def create_activity_invite(self, event:str, **kwargs) -> Invite: |
| 1042 | + """|coro| |
| 1043 | +
|
| 1044 | + A shortcut method that creates an instant activity invite. |
| 1045 | +
|
| 1046 | + You must have the :attr:`~discord.Permissions.create_instant_invite` permission to |
| 1047 | + do this. |
| 1048 | +
|
| 1049 | + Parameters |
| 1050 | + ------------ |
| 1051 | + event: :class:`str` |
| 1052 | + The event to create an invite for. |
| 1053 | + max_age: :class:`int` |
| 1054 | + How long the invite should last in seconds. If it's 0 then the invite |
| 1055 | + doesn't expire. Defaults to ``0``. |
| 1056 | + max_uses: :class:`int` |
| 1057 | + How many uses the invite could be used for. If it's 0 then there |
| 1058 | + are unlimited uses. Defaults to ``0``. |
| 1059 | + temporary: :class:`bool` |
| 1060 | + Denotes that the invite grants temporary membership |
| 1061 | + (i.e. they get kicked after they disconnect). Defaults to ``False``. |
| 1062 | + unique: :class:`bool` |
| 1063 | + Indicates if a unique invite URL should be created. Defaults to True. |
| 1064 | + If this is set to ``False`` then it will return a previously created |
| 1065 | + invite. |
| 1066 | + reason: Optional[:class:`str`] |
| 1067 | + The reason for creating this invite. Shows up on the audit log. |
| 1068 | +
|
| 1069 | +
|
| 1070 | + Raises |
| 1071 | + ------- |
| 1072 | + InvalidArgument |
| 1073 | + If the event is not a valid event. |
| 1074 | + ~discord.HTTPException |
| 1075 | + Invite creation failed. |
| 1076 | +
|
| 1077 | + Returns |
| 1078 | + -------- |
| 1079 | + :class:`~discord.Invite` |
| 1080 | + The invite that was created. |
| 1081 | + """ |
| 1082 | + |
| 1083 | + application_ids = { |
| 1084 | + 'youtube' : 755600276941176913, |
| 1085 | + 'poker' : 755827207812677713, |
| 1086 | + 'betrayal': 773336526917861400, |
| 1087 | + 'fishing' : 814288819477020702, |
| 1088 | + 'chess' : 832012774040141894, |
| 1089 | + } |
| 1090 | + event = application_ids.get(event) |
| 1091 | + if event is None: |
| 1092 | + raise InvalidArgument('Invalid event.') |
| 1093 | + |
| 1094 | + return await self.create_invite( |
| 1095 | + target_type=InviteTarget.embedded_application, |
| 1096 | + target_application_id=event, |
| 1097 | + **kwargs |
| 1098 | + ) |
1040 | 1099 |
|
1041 | 1100 | class StageChannel(VocalGuildChannel): |
1042 | 1101 | """Represents a Discord guild stage channel. |
|
0 commit comments