|
|
@ -304,6 +304,7 @@ class Guild(Hashable): |
|
|
|
'owner_application_id', |
|
|
|
'command_counts', |
|
|
|
'widget_enabled', |
|
|
|
'_widget_channel_id', |
|
|
|
'_members', |
|
|
|
'_channels', |
|
|
|
'_icon', |
|
|
@ -315,7 +316,6 @@ class Guild(Hashable): |
|
|
|
'_splash', |
|
|
|
'_voice_states', |
|
|
|
'_afk_channel_id', |
|
|
|
'_widget_channel_id', |
|
|
|
'_system_channel_id', |
|
|
|
'_system_channel_flags', |
|
|
|
'_discovery_splash', |
|
|
@ -525,13 +525,13 @@ class Guild(Hashable): |
|
|
|
self.premium_subscription_count: int = guild.get('premium_subscription_count') or 0 |
|
|
|
self.vanity_url_code: Optional[str] = guild.get('vanity_url_code') |
|
|
|
self.widget_enabled: bool = guild.get('widget_enabled', False) |
|
|
|
self._widget_channel_id: Optional[int] = utils._get_as_snowflake(guild, 'widget_channel_id') |
|
|
|
self._system_channel_flags: int = guild.get('system_channel_flags', 0) |
|
|
|
self.preferred_locale: Locale = try_enum(Locale, guild.get('preferred_locale', 'en-US')) |
|
|
|
self._discovery_splash: Optional[str] = guild.get('discovery_splash') |
|
|
|
self._rules_channel_id: Optional[int] = utils._get_as_snowflake(guild, 'rules_channel_id') |
|
|
|
self._public_updates_channel_id: Optional[int] = utils._get_as_snowflake(guild, 'public_updates_channel_id') |
|
|
|
self._afk_channel_id: Optional[int] = utils._get_as_snowflake(guild, 'afk_channel_id') |
|
|
|
self._widget_channel_id: Optional[int] = utils._get_as_snowflake(guild, 'widget_channel_id') |
|
|
|
self.nsfw_level: NSFWLevel = try_enum(NSFWLevel, guild.get('nsfw_level', 0)) |
|
|
|
self.mfa_level: MFALevel = try_enum(MFALevel, guild.get('mfa_level', 0)) |
|
|
|
self.approximate_presence_count: Optional[int] = guild.get('approximate_presence_count') |
|
|
@ -801,7 +801,7 @@ class Guild(Hashable): |
|
|
|
def get_emoji(self, emoji_id: int, /) -> Optional[Emoji]: |
|
|
|
"""Returns an emoji with the given ID. |
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
|
.. versionadded:: 2.0 |
|
|
|
|
|
|
|
Parameters |
|
|
|
---------- |
|
|
@ -867,11 +867,13 @@ class Guild(Hashable): |
|
|
|
return channel_id and self._channels.get(channel_id) # type: ignore |
|
|
|
|
|
|
|
@property |
|
|
|
def widget_channel(self) -> Optional[GuildChannel]: |
|
|
|
"""Optional[:class:`TextChannel`]: Returns the channel the |
|
|
|
widget will generate an invite to by default. |
|
|
|
def widget_channel(self) -> Optional[Union[TextChannel, ForumChannel, VoiceChannel, StageChannel]]: |
|
|
|
"""Optional[Union[:class:`TextChannel`, :class:`ForumChannel`, :class:`VoiceChannel`, :class:`StageChannel`]]: Returns |
|
|
|
the widget channel of the guild. |
|
|
|
|
|
|
|
If no channel is set, then this returns ``None``. |
|
|
|
|
|
|
|
.. versionadded:: 2.0 |
|
|
|
""" |
|
|
|
channel_id = self._widget_channel_id |
|
|
|
return channel_id and self._channels.get(channel_id) # type: ignore |
|
|
@ -1366,7 +1368,7 @@ class Guild(Hashable): |
|
|
|
default_thread_slowmode_delay: :class:`int` |
|
|
|
The default slowmode delay in seconds for threads created in the text channel. |
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
|
.. versionadded:: 2.0 |
|
|
|
reason: Optional[:class:`str`] |
|
|
|
The reason for creating this channel. Shows up on the audit log. |
|
|
|
|
|
|
@ -1859,6 +1861,8 @@ class Guild(Hashable): |
|
|
|
premium_progress_bar_enabled: bool = MISSING, |
|
|
|
discoverable: bool = MISSING, |
|
|
|
invites_disabled: bool = MISSING, |
|
|
|
widget_enabled: bool = MISSING, |
|
|
|
widget_channel: Optional[Snowflake] = MISSING, |
|
|
|
) -> Guild: |
|
|
|
r"""|coro| |
|
|
|
|
|
|
@ -1891,6 +1895,9 @@ class Guild(Hashable): |
|
|
|
.. versionchanged:: 2.0 |
|
|
|
The ``discoverable`` and ``invites_disabled`` keyword parameters were added. |
|
|
|
|
|
|
|
.. versionchanged:: 2.0 |
|
|
|
The ``widget_enabled`` and ``widget_channel`` keyword parameters were added. |
|
|
|
|
|
|
|
Parameters |
|
|
|
---------- |
|
|
|
name: :class:`str` |
|
|
@ -1954,6 +1961,10 @@ class Guild(Hashable): |
|
|
|
Whether server discovery is enabled for this guild. |
|
|
|
invites_disabled: :class:`bool` |
|
|
|
Whether joining via invites should be disabled for the guild. |
|
|
|
widget_enabled: :class:`bool` |
|
|
|
Whether to enable the widget for the guild. |
|
|
|
widget_channel: Optional[:class:`abc.Snowflake`] |
|
|
|
The new widget channel. ``None`` removes the widget channel. |
|
|
|
reason: Optional[:class:`str`] |
|
|
|
The reason for editing this guild. Shows up on the audit log. |
|
|
|
|
|
|
@ -2105,6 +2116,15 @@ class Guild(Hashable): |
|
|
|
if premium_progress_bar_enabled is not MISSING: |
|
|
|
fields['premium_progress_bar_enabled'] = premium_progress_bar_enabled |
|
|
|
|
|
|
|
widget_payload: EditWidgetSettings = {} |
|
|
|
if widget_channel is not MISSING: |
|
|
|
widget_payload['channel_id'] = None if widget_channel is None else widget_channel.id |
|
|
|
if widget_enabled is not MISSING: |
|
|
|
widget_payload['enabled'] = widget_enabled |
|
|
|
|
|
|
|
if widget_payload: |
|
|
|
await self._state.http.edit_widget(self.id, payload=widget_payload, reason=reason) |
|
|
|
|
|
|
|
data = await http.edit_guild(self.id, reason=reason, **fields) |
|
|
|
return Guild(data=data, state=self._state) |
|
|
|
|
|
|
@ -3890,7 +3910,7 @@ class Guild(Hashable): |
|
|
|
) -> None: |
|
|
|
"""|coro| |
|
|
|
|
|
|
|
Edits the widget of the guild. |
|
|
|
Edits the widget of the guild. This can also be done with :attr:`~Guild.edit`. |
|
|
|
|
|
|
|
You must have :attr:`~Permissions.manage_guild` to do this. |
|
|
|
|
|
|
@ -3918,7 +3938,8 @@ class Guild(Hashable): |
|
|
|
if enabled is not MISSING: |
|
|
|
payload['enabled'] = enabled |
|
|
|
|
|
|
|
await self._state.http.edit_widget(self.id, payload=payload, reason=reason) |
|
|
|
if payload: |
|
|
|
await self._state.http.edit_widget(self.id, payload=payload, reason=reason) |
|
|
|
|
|
|
|
async def welcome_screen(self) -> WelcomeScreen: |
|
|
|
"""|coro| |
|
|
|