|
71 | 71 | from .iterators import AuditLogIterator, BanIterator, MemberIterator
|
72 | 72 | from .member import Member, VoiceState
|
73 | 73 | from .mixins import Hashable
|
| 74 | +from .onboarding import Onboarding |
74 | 75 | from .permissions import PermissionOverwrite
|
75 | 76 | from .role import Role
|
76 | 77 | from .scheduled_events import ScheduledEvent, ScheduledEventLocation
|
@@ -3842,6 +3843,88 @@ async def create_auto_moderation_rule(
|
3842 | 3843 | )
|
3843 | 3844 | return AutoModRule(state=self._state, data=data)
|
3844 | 3845 |
|
| 3846 | + async def onboarding(self): |
| 3847 | + """|coro| |
| 3848 | +
|
| 3849 | + Returns the :class:`Onboarding` flow for the guild. |
| 3850 | +
|
| 3851 | + .. versionadded:: 2.5 |
| 3852 | +
|
| 3853 | + Returns |
| 3854 | + ------- |
| 3855 | + :class:`Onboarding` |
| 3856 | + The onboarding flow for the guild. |
| 3857 | +
|
| 3858 | + Raises |
| 3859 | + ------ |
| 3860 | + HTTPException |
| 3861 | + Retrieving the onboarding flow failed somehow. |
| 3862 | + """ |
| 3863 | + data = await self._state.http.get_onboarding(self.id) |
| 3864 | + return Onboarding(data=data, guild=self) |
| 3865 | + |
| 3866 | + async def edit_onboarding( |
| 3867 | + self, |
| 3868 | + *, |
| 3869 | + prompts: list[OnboardingPrompt] | None = MISSING, |
| 3870 | + default_channels: list[Snowflake] | None = MISSING, |
| 3871 | + enabled: bool | None = MISSING, |
| 3872 | + mode: OnboardingMode | None = MISSING, |
| 3873 | + reason: str | None = MISSING, |
| 3874 | + ) -> Onboarding: |
| 3875 | + """|coro| |
| 3876 | +
|
| 3877 | + A shorthand for :attr:`Onboarding.edit` without fetching the onboarding flow. |
| 3878 | +
|
| 3879 | + You must have the :attr:`~Permissions.manage_guild` and :attr:`~Permissions.manage_roles` permissions in the |
| 3880 | + guild to do this. |
| 3881 | +
|
| 3882 | + Parameters |
| 3883 | + ---------- |
| 3884 | +
|
| 3885 | + prompts: Optional[List[:class:`OnboardingPrompt`]] |
| 3886 | + The new list of prompts for this flow. |
| 3887 | + default_channels: Optional[List[:class:`Snowflake`]] |
| 3888 | + The new default channels that users are opted into. |
| 3889 | + enabled: Optional[:class:`bool`] |
| 3890 | + Whether onboarding should be enabled. Setting this to ``True`` requires |
| 3891 | + the guild to have ``COMMUNITY`` in :attr:`~Guild.features` and at |
| 3892 | + least 7 ``default_channels``. |
| 3893 | + mode: Optional[:class:`OnboardingMode`] |
| 3894 | + The new onboarding mode. |
| 3895 | + reason: Optional[:class:`str`] |
| 3896 | + The reason that shows up on Audit log. |
| 3897 | +
|
| 3898 | + Returns |
| 3899 | + ------- |
| 3900 | + :class:`Onboarding` |
| 3901 | + The updated onboarding flow. |
| 3902 | +
|
| 3903 | + Raises |
| 3904 | + ------ |
| 3905 | +
|
| 3906 | + HTTPException |
| 3907 | + Editing the onboarding flow failed somehow. |
| 3908 | + Forbidden |
| 3909 | + You don't have permissions to edit the onboarding flow. |
| 3910 | + """ |
| 3911 | + |
| 3912 | + fields: dict[str, Any] = {} |
| 3913 | + if prompts is not MISSING: |
| 3914 | + fields["prompts"] = [prompt.to_dict() for prompt in prompts] |
| 3915 | + |
| 3916 | + if default_channels is not MISSING: |
| 3917 | + fields["default_channel_ids"] = [channel.id for channel in default_channels] |
| 3918 | + |
| 3919 | + if enabled is not MISSING: |
| 3920 | + fields["enabled"] = enabled |
| 3921 | + |
| 3922 | + if mode is not MISSING: |
| 3923 | + fields["mode"] = mode.value |
| 3924 | + |
| 3925 | + new = await self._state.http.edit_onboarding(self.id, fields, reason=reason) |
| 3926 | + return Onboarding(data=new, guild=self) |
| 3927 | + |
3845 | 3928 | async def delete_auto_moderation_rule(
|
3846 | 3929 | self,
|
3847 | 3930 | id: int,
|
|
0 commit comments