Add support for guild onboarding

Co-authored-by: Josh <8677174+bijij@users.noreply.github.com>
Co-authored-by: Josh <josh.ja.butt@gmail.com>
Co-authored-by: numbermaniac <5206120+numbermaniac@users.noreply.github.com>
Co-authored-by: Andrin <65789180+Puncher1@users.noreply.github.com>
Co-authored-by: Andrin Schaller <65789180+codeofandrin@users.noreply.github.com>
Co-authored-by: DA344 <108473820+DA-344@users.noreply.github.com>
This commit is contained in:
Soheab
2025-08-08 09:10:32 +02:00
committed by GitHub
parent 21fed315c7
commit 7b3f798044
13 changed files with 869 additions and 13 deletions

View File

@ -76,6 +76,7 @@ from .enums import (
AutoModRuleEventType,
ForumOrderType,
ForumLayoutType,
OnboardingMode,
)
from .mixins import Hashable
from .user import User
@ -91,6 +92,7 @@ from .sticker import GuildSticker
from .file import File
from .audit_logs import AuditLogEntry
from .object import OLDEST_OBJECT, Object
from .onboarding import Onboarding
from .welcome_screen import WelcomeScreen, WelcomeChannel
from .automod import AutoModRule, AutoModTrigger, AutoModRuleAction
from .partial_emoji import _EmojiTag, PartialEmoji
@ -139,6 +141,7 @@ if TYPE_CHECKING:
from .types.widget import EditWidgetSettings
from .types.audit_log import AuditLogEvent
from .message import EmojiInputType
from .onboarding import OnboardingPrompt
VocalGuildChannel = Union[VoiceChannel, StageChannel]
GuildChannel = Union[VocalGuildChannel, ForumChannel, TextChannel, CategoryChannel]
@ -4879,3 +4882,74 @@ class Guild(Hashable):
data = await self._state.http.create_soundboard_sound(self.id, reason=reason, **payload)
return SoundboardSound(guild=self, state=self._state, data=data)
async def onboarding(self) -> Onboarding:
"""|coro|
Fetches the onboarding configuration for this guild.
.. versionadded:: 2.6
Returns
--------
:class:`Onboarding`
The onboarding configuration that was fetched.
"""
data = await self._state.http.get_guild_onboarding(self.id)
return Onboarding(data=data, guild=self, state=self._state)
async def edit_onboarding(
self,
*,
prompts: List[OnboardingPrompt] = MISSING,
default_channels: List[Snowflake] = MISSING,
enabled: bool = MISSING,
mode: OnboardingMode = MISSING,
reason: str = MISSING,
) -> Onboarding:
"""|coro|
Edits the onboarding configuration for this guild.
You must have :attr:`Permissions.manage_guild` and
:attr:`Permissions.manage_roles` to do this.
.. versionadded:: 2.6
Parameters
-----------
prompts: List[:class:`OnboardingPrompt`]
The prompts that will be shown to new members.
This overrides the existing prompts and its options.
default_channels: List[:class:`abc.Snowflake`]
The channels that will be used as the default channels for new members.
This overrides the existing default channels.
enabled: :class:`bool`
Whether the onboarding configuration is enabled.
This overrides the existing enabled state.
mode: :class:`OnboardingMode`
The mode that will be used for the onboarding configuration.
reason: :class:`str`
The reason for editing the onboarding configuration. Shows up on the audit log.
Raises
-------
Forbidden
You do not have permissions to edit the onboarding configuration.
HTTPException
Editing the onboarding configuration failed.
Returns
--------
:class:`Onboarding`
The new onboarding configuration.
"""
data = await self._state.http.edit_guild_onboarding(
self.id,
prompts=[p.to_dict(id=i) for i, p in enumerate(prompts)] if prompts is not MISSING else None,
default_channel_ids=[c.id for c in default_channels] if default_channels is not MISSING else None,
enabled=enabled if enabled is not MISSING else None,
mode=mode.value if mode is not MISSING else None,
reason=reason if reason is not MISSING else None,
)
return Onboarding(data=data, guild=self, state=self._state)