|
@ -73,6 +73,8 @@ from .enums import ( |
|
|
MFALevel, |
|
|
MFALevel, |
|
|
Locale, |
|
|
Locale, |
|
|
AutoModRuleEventType, |
|
|
AutoModRuleEventType, |
|
|
|
|
|
ForumOrderType, |
|
|
|
|
|
ForumLayoutType, |
|
|
) |
|
|
) |
|
|
from .mixins import Hashable |
|
|
from .mixins import Hashable |
|
|
from .user import User |
|
|
from .user import User |
|
@ -91,6 +93,7 @@ from .object import OLDEST_OBJECT, Object |
|
|
from .onboarding import Onboarding |
|
|
from .onboarding import Onboarding |
|
|
from .welcome_screen import WelcomeScreen, WelcomeChannel |
|
|
from .welcome_screen import WelcomeScreen, WelcomeChannel |
|
|
from .automod import AutoModRule, AutoModTrigger, AutoModRuleAction |
|
|
from .automod import AutoModRule, AutoModTrigger, AutoModRuleAction |
|
|
|
|
|
from .partial_emoji import _EmojiTag, PartialEmoji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = ( |
|
|
__all__ = ( |
|
@ -130,6 +133,7 @@ if TYPE_CHECKING: |
|
|
from .types.integration import IntegrationType |
|
|
from .types.integration import IntegrationType |
|
|
from .types.snowflake import SnowflakeList |
|
|
from .types.snowflake import SnowflakeList |
|
|
from .types.widget import EditWidgetSettings |
|
|
from .types.widget import EditWidgetSettings |
|
|
|
|
|
from .message import EmojiInputType |
|
|
|
|
|
|
|
|
VocalGuildChannel = Union[VoiceChannel, StageChannel] |
|
|
VocalGuildChannel = Union[VoiceChannel, StageChannel] |
|
|
GuildChannel = Union[VocalGuildChannel, ForumChannel, TextChannel, CategoryChannel] |
|
|
GuildChannel = Union[VocalGuildChannel, ForumChannel, TextChannel, CategoryChannel] |
|
@ -290,6 +294,7 @@ class Guild(Hashable): |
|
|
'mfa_level', |
|
|
'mfa_level', |
|
|
'vanity_url_code', |
|
|
'vanity_url_code', |
|
|
'widget_enabled', |
|
|
'widget_enabled', |
|
|
|
|
|
'_widget_channel_id', |
|
|
'_members', |
|
|
'_members', |
|
|
'_channels', |
|
|
'_channels', |
|
|
'_icon', |
|
|
'_icon', |
|
@ -478,6 +483,7 @@ class Guild(Hashable): |
|
|
self.premium_subscription_count: int = guild.get('premium_subscription_count') or 0 |
|
|
self.premium_subscription_count: int = guild.get('premium_subscription_count') or 0 |
|
|
self.vanity_url_code: Optional[str] = guild.get('vanity_url_code') |
|
|
self.vanity_url_code: Optional[str] = guild.get('vanity_url_code') |
|
|
self.widget_enabled: bool = guild.get('widget_enabled', False) |
|
|
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._system_channel_flags: int = guild.get('system_channel_flags', 0) |
|
|
self.preferred_locale: Locale = try_enum(Locale, guild.get('preferred_locale', 'en-US')) |
|
|
self.preferred_locale: Locale = try_enum(Locale, guild.get('preferred_locale', 'en-US')) |
|
|
self._discovery_splash: Optional[str] = guild.get('discovery_splash') |
|
|
self._discovery_splash: Optional[str] = guild.get('discovery_splash') |
|
@ -737,6 +743,26 @@ class Guild(Hashable): |
|
|
""" |
|
|
""" |
|
|
return self._threads.get(thread_id) |
|
|
return self._threads.get(thread_id) |
|
|
|
|
|
|
|
|
|
|
|
def get_emoji(self, emoji_id: int, /) -> Optional[Emoji]: |
|
|
|
|
|
"""Returns an emoji with the given ID. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
|
|
|
|
|
|
|
|
|
Parameters |
|
|
|
|
|
---------- |
|
|
|
|
|
emoji_id: int |
|
|
|
|
|
The ID to search for. |
|
|
|
|
|
|
|
|
|
|
|
Returns |
|
|
|
|
|
-------- |
|
|
|
|
|
Optional[:class:`Emoji`] |
|
|
|
|
|
The returned Emoji or ``None`` if not found. |
|
|
|
|
|
""" |
|
|
|
|
|
emoji = self._state.get_emoji(emoji_id) |
|
|
|
|
|
if emoji and emoji.guild == self: |
|
|
|
|
|
return emoji |
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def system_channel(self) -> Optional[TextChannel]: |
|
|
def system_channel(self) -> Optional[TextChannel]: |
|
|
"""Optional[:class:`TextChannel`]: Returns the guild's channel used for system messages. |
|
|
"""Optional[:class:`TextChannel`]: Returns the guild's channel used for system messages. |
|
@ -776,6 +802,18 @@ class Guild(Hashable): |
|
|
channel_id = self._public_updates_channel_id |
|
|
channel_id = self._public_updates_channel_id |
|
|
return channel_id and self._channels.get(channel_id) # type: ignore |
|
|
return channel_id and self._channels.get(channel_id) # type: ignore |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
|
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.3 |
|
|
|
|
|
""" |
|
|
|
|
|
channel_id = self._widget_channel_id |
|
|
|
|
|
return channel_id and self._channels.get(channel_id) # type: ignore |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def emoji_limit(self) -> int: |
|
|
def emoji_limit(self) -> int: |
|
|
""":class:`int`: The maximum number of emoji slots this guild has.""" |
|
|
""":class:`int`: The maximum number of emoji slots this guild has.""" |
|
@ -1200,6 +1238,7 @@ class Guild(Hashable): |
|
|
nsfw: bool = MISSING, |
|
|
nsfw: bool = MISSING, |
|
|
overwrites: Mapping[Union[Role, Member], PermissionOverwrite] = MISSING, |
|
|
overwrites: Mapping[Union[Role, Member], PermissionOverwrite] = MISSING, |
|
|
default_auto_archive_duration: int = MISSING, |
|
|
default_auto_archive_duration: int = MISSING, |
|
|
|
|
|
default_thread_slowmode_delay: int = MISSING, |
|
|
) -> TextChannel: |
|
|
) -> TextChannel: |
|
|
"""|coro| |
|
|
"""|coro| |
|
|
|
|
|
|
|
@ -1273,6 +1312,10 @@ class Guild(Hashable): |
|
|
Must be one of ``60``, ``1440``, ``4320``, or ``10080``. |
|
|
Must be one of ``60``, ``1440``, ``4320``, or ``10080``. |
|
|
|
|
|
|
|
|
.. versionadded:: 2.0 |
|
|
.. versionadded:: 2.0 |
|
|
|
|
|
default_thread_slowmode_delay: :class:`int` |
|
|
|
|
|
The default slowmode delay in seconds for threads created in the text channel. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
reason: Optional[:class:`str`] |
|
|
reason: Optional[:class:`str`] |
|
|
The reason for creating this channel. Shows up on the audit log. |
|
|
The reason for creating this channel. Shows up on the audit log. |
|
|
|
|
|
|
|
@ -1305,7 +1348,10 @@ class Guild(Hashable): |
|
|
options['nsfw'] = nsfw |
|
|
options['nsfw'] = nsfw |
|
|
|
|
|
|
|
|
if default_auto_archive_duration is not MISSING: |
|
|
if default_auto_archive_duration is not MISSING: |
|
|
options["default_auto_archive_duration"] = default_auto_archive_duration |
|
|
options['default_auto_archive_duration'] = default_auto_archive_duration |
|
|
|
|
|
|
|
|
|
|
|
if default_thread_slowmode_delay is not MISSING: |
|
|
|
|
|
options['default_thread_rate_limit_per_user'] = default_thread_slowmode_delay |
|
|
|
|
|
|
|
|
data = await self._create_channel( |
|
|
data = await self._create_channel( |
|
|
name, |
|
|
name, |
|
@ -1577,6 +1623,9 @@ class Guild(Hashable): |
|
|
reason: Optional[str] = None, |
|
|
reason: Optional[str] = None, |
|
|
default_auto_archive_duration: int = MISSING, |
|
|
default_auto_archive_duration: int = MISSING, |
|
|
default_thread_slowmode_delay: int = MISSING, |
|
|
default_thread_slowmode_delay: int = MISSING, |
|
|
|
|
|
default_sort_order: ForumOrderType = MISSING, |
|
|
|
|
|
default_reaction_emoji: EmojiInputType = MISSING, |
|
|
|
|
|
default_layout: ForumLayoutType = MISSING, |
|
|
available_tags: Sequence[ForumTag] = MISSING, |
|
|
available_tags: Sequence[ForumTag] = MISSING, |
|
|
) -> ForumChannel: |
|
|
) -> ForumChannel: |
|
|
"""|coro| |
|
|
"""|coro| |
|
@ -1594,6 +1643,10 @@ class Guild(Hashable): |
|
|
----------- |
|
|
----------- |
|
|
name: :class:`str` |
|
|
name: :class:`str` |
|
|
The channel's name. |
|
|
The channel's name. |
|
|
|
|
|
overwrites: Dict[Union[:class:`Role`, :class:`Member`], :class:`PermissionOverwrite`] |
|
|
|
|
|
A :class:`dict` of target (either a role or a member) to |
|
|
|
|
|
:class:`PermissionOverwrite` to apply upon creation of a channel. |
|
|
|
|
|
Useful for creating secret channels. |
|
|
topic: :class:`str` |
|
|
topic: :class:`str` |
|
|
The channel's topic. |
|
|
The channel's topic. |
|
|
category: Optional[:class:`CategoryChannel`] |
|
|
category: Optional[:class:`CategoryChannel`] |
|
@ -1617,6 +1670,19 @@ class Guild(Hashable): |
|
|
The default slowmode delay in seconds for threads created in this forum. |
|
|
The default slowmode delay in seconds for threads created in this forum. |
|
|
|
|
|
|
|
|
.. versionadded:: 2.1 |
|
|
.. versionadded:: 2.1 |
|
|
|
|
|
default_sort_order: :class:`ForumOrderType` |
|
|
|
|
|
The default sort order for posts in this forum channel. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
|
|
|
default_reaction_emoji: Union[:class:`Emoji`, :class:`PartialEmoji`, :class:`str`] |
|
|
|
|
|
The default reaction emoji for threads created in this forum to show in the |
|
|
|
|
|
add reaction button. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
|
|
|
default_layout: :class:`ForumLayoutType` |
|
|
|
|
|
The default layout for posts in this forum. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
available_tags: Sequence[:class:`ForumTag`] |
|
|
available_tags: Sequence[:class:`ForumTag`] |
|
|
The available tags for this forum channel. |
|
|
The available tags for this forum channel. |
|
|
|
|
|
|
|
@ -1656,6 +1722,30 @@ class Guild(Hashable): |
|
|
if default_thread_slowmode_delay is not MISSING: |
|
|
if default_thread_slowmode_delay is not MISSING: |
|
|
options['default_thread_rate_limit_per_user'] = default_thread_slowmode_delay |
|
|
options['default_thread_rate_limit_per_user'] = default_thread_slowmode_delay |
|
|
|
|
|
|
|
|
|
|
|
if default_sort_order is not MISSING: |
|
|
|
|
|
if not isinstance(default_sort_order, ForumOrderType): |
|
|
|
|
|
raise TypeError( |
|
|
|
|
|
f'default_sort_order parameter must be a ForumOrderType not {default_sort_order.__class__.__name__}' |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
options['default_sort_order'] = default_sort_order.value |
|
|
|
|
|
|
|
|
|
|
|
if default_reaction_emoji is not MISSING: |
|
|
|
|
|
if isinstance(default_reaction_emoji, _EmojiTag): |
|
|
|
|
|
options['default_reaction_emoji'] = default_reaction_emoji._to_partial()._to_forum_tag_payload() |
|
|
|
|
|
elif isinstance(default_reaction_emoji, str): |
|
|
|
|
|
options['default_reaction_emoji'] = PartialEmoji.from_str(default_reaction_emoji)._to_forum_tag_payload() |
|
|
|
|
|
else: |
|
|
|
|
|
raise ValueError(f'default_reaction_emoji parameter must be either Emoji, PartialEmoji, or str') |
|
|
|
|
|
|
|
|
|
|
|
if default_layout is not MISSING: |
|
|
|
|
|
if not isinstance(default_layout, ForumLayoutType): |
|
|
|
|
|
raise TypeError( |
|
|
|
|
|
f'default_layout parameter must be a ForumLayoutType not {default_layout.__class__.__name__}' |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
options['default_forum_layout'] = default_layout.value |
|
|
|
|
|
|
|
|
if available_tags is not MISSING: |
|
|
if available_tags is not MISSING: |
|
|
options['available_tags'] = [t.to_dict() for t in available_tags] |
|
|
options['available_tags'] = [t.to_dict() for t in available_tags] |
|
|
|
|
|
|
|
@ -1728,6 +1818,9 @@ class Guild(Hashable): |
|
|
premium_progress_bar_enabled: bool = MISSING, |
|
|
premium_progress_bar_enabled: bool = MISSING, |
|
|
discoverable: bool = MISSING, |
|
|
discoverable: bool = MISSING, |
|
|
invites_disabled: bool = MISSING, |
|
|
invites_disabled: bool = MISSING, |
|
|
|
|
|
widget_enabled: bool = MISSING, |
|
|
|
|
|
widget_channel: Optional[Snowflake] = MISSING, |
|
|
|
|
|
mfa_level: MFALevel = MISSING, |
|
|
) -> Guild: |
|
|
) -> Guild: |
|
|
r"""|coro| |
|
|
r"""|coro| |
|
|
|
|
|
|
|
@ -1735,12 +1828,6 @@ class Guild(Hashable): |
|
|
|
|
|
|
|
|
You must have :attr:`~Permissions.manage_guild` to edit the guild. |
|
|
You must have :attr:`~Permissions.manage_guild` to edit the guild. |
|
|
|
|
|
|
|
|
.. versionchanged:: 1.4 |
|
|
|
|
|
The ``rules_channel`` and ``public_updates_channel`` keyword parameters were added. |
|
|
|
|
|
|
|
|
|
|
|
.. versionchanged:: 2.0 |
|
|
|
|
|
The ``discovery_splash`` and ``community`` keyword parameters were added. |
|
|
|
|
|
|
|
|
|
|
|
.. versionchanged:: 2.0 |
|
|
.. versionchanged:: 2.0 |
|
|
The newly updated guild is returned. |
|
|
The newly updated guild is returned. |
|
|
|
|
|
|
|
@ -1751,15 +1838,6 @@ class Guild(Hashable): |
|
|
This function will now raise :exc:`TypeError` or |
|
|
This function will now raise :exc:`TypeError` or |
|
|
:exc:`ValueError` instead of ``InvalidArgument``. |
|
|
:exc:`ValueError` instead of ``InvalidArgument``. |
|
|
|
|
|
|
|
|
.. versionchanged:: 2.0 |
|
|
|
|
|
The ``preferred_locale`` keyword parameter now accepts an enum instead of :class:`str`. |
|
|
|
|
|
|
|
|
|
|
|
.. versionchanged:: 2.0 |
|
|
|
|
|
The ``premium_progress_bar_enabled`` keyword parameter was added. |
|
|
|
|
|
|
|
|
|
|
|
.. versionchanged:: 2.1 |
|
|
|
|
|
The ``discoverable`` and ``invites_disabled`` keyword parameters were added. |
|
|
|
|
|
|
|
|
|
|
|
Parameters |
|
|
Parameters |
|
|
---------- |
|
|
---------- |
|
|
name: :class:`str` |
|
|
name: :class:`str` |
|
@ -1785,9 +1863,13 @@ class Guild(Hashable): |
|
|
Only PNG/JPEG supported. Could be ``None`` to denote removing the |
|
|
Only PNG/JPEG supported. Could be ``None`` to denote removing the |
|
|
splash. This is only available to guilds that contain ``DISCOVERABLE`` |
|
|
splash. This is only available to guilds that contain ``DISCOVERABLE`` |
|
|
in :attr:`Guild.features`. |
|
|
in :attr:`Guild.features`. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.0 |
|
|
community: :class:`bool` |
|
|
community: :class:`bool` |
|
|
Whether the guild should be a Community guild. If set to ``True``\, both ``rules_channel`` |
|
|
Whether the guild should be a Community guild. If set to ``True``\, both ``rules_channel`` |
|
|
and ``public_updates_channel`` parameters are required. |
|
|
and ``public_updates_channel`` parameters are required. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.0 |
|
|
afk_channel: Optional[:class:`VoiceChannel`] |
|
|
afk_channel: Optional[:class:`VoiceChannel`] |
|
|
The new channel that is the AFK channel. Could be ``None`` for no AFK channel. |
|
|
The new channel that is the AFK channel. Could be ``None`` for no AFK channel. |
|
|
afk_timeout: :class:`int` |
|
|
afk_timeout: :class:`int` |
|
@ -1809,20 +1891,47 @@ class Guild(Hashable): |
|
|
The new system channel settings to use with the new system channel. |
|
|
The new system channel settings to use with the new system channel. |
|
|
preferred_locale: :class:`Locale` |
|
|
preferred_locale: :class:`Locale` |
|
|
The new preferred locale for the guild. Used as the primary language in the guild. |
|
|
The new preferred locale for the guild. Used as the primary language in the guild. |
|
|
|
|
|
|
|
|
|
|
|
.. versionchanged:: 2.0 |
|
|
|
|
|
|
|
|
|
|
|
Now accepts an enum instead of :class:`str`. |
|
|
rules_channel: Optional[:class:`TextChannel`] |
|
|
rules_channel: Optional[:class:`TextChannel`] |
|
|
The new channel that is used for rules. This is only available to |
|
|
The new channel that is used for rules. This is only available to |
|
|
guilds that contain ``COMMUNITY`` in :attr:`Guild.features`. Could be ``None`` for no rules |
|
|
guilds that contain ``COMMUNITY`` in :attr:`Guild.features`. Could be ``None`` for no rules |
|
|
channel. |
|
|
channel. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 1.4 |
|
|
public_updates_channel: Optional[:class:`TextChannel`] |
|
|
public_updates_channel: Optional[:class:`TextChannel`] |
|
|
The new channel that is used for public updates from Discord. This is only available to |
|
|
The new channel that is used for public updates from Discord. This is only available to |
|
|
guilds that contain ``COMMUNITY`` in :attr:`Guild.features`. Could be ``None`` for no |
|
|
guilds that contain ``COMMUNITY`` in :attr:`Guild.features`. Could be ``None`` for no |
|
|
public updates channel. |
|
|
public updates channel. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 1.4 |
|
|
premium_progress_bar_enabled: :class:`bool` |
|
|
premium_progress_bar_enabled: :class:`bool` |
|
|
Whether the premium AKA server boost level progress bar should be enabled for the guild. |
|
|
Whether the premium AKA server boost level progress bar should be enabled for the guild. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.0 |
|
|
discoverable: :class:`bool` |
|
|
discoverable: :class:`bool` |
|
|
Whether server discovery is enabled for this guild. |
|
|
Whether server discovery is enabled for this guild. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.1 |
|
|
invites_disabled: :class:`bool` |
|
|
invites_disabled: :class:`bool` |
|
|
Whether joining via invites should be disabled for the guild. |
|
|
Whether joining via invites should be disabled for the guild. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.1 |
|
|
|
|
|
widget_enabled: :class:`bool` |
|
|
|
|
|
Whether to enable the widget for the guild. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
|
|
|
widget_channel: Optional[:class:`abc.Snowflake`] |
|
|
|
|
|
The new widget channel. ``None`` removes the widget channel. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
|
|
|
mfa_level: :class:`MFALevel` |
|
|
|
|
|
The new guild's Multi-Factor Authentication requirement level. |
|
|
|
|
|
Note that you must be owner of the guild to do this. |
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.3 |
|
|
reason: Optional[:class:`str`] |
|
|
reason: Optional[:class:`str`] |
|
|
The reason for editing this guild. Shows up on the audit log. |
|
|
The reason for editing this guild. Shows up on the audit log. |
|
|
|
|
|
|
|
@ -1838,7 +1947,7 @@ class Guild(Hashable): |
|
|
guild and request an ownership transfer. |
|
|
guild and request an ownership transfer. |
|
|
TypeError |
|
|
TypeError |
|
|
The type passed to the ``default_notifications``, ``verification_level``, |
|
|
The type passed to the ``default_notifications``, ``verification_level``, |
|
|
``explicit_content_filter``, or ``system_channel_flags`` parameter was |
|
|
``explicit_content_filter``, ``system_channel_flags``, or ``mfa_level`` parameter was |
|
|
of the incorrect type. |
|
|
of the incorrect type. |
|
|
|
|
|
|
|
|
Returns |
|
|
Returns |
|
@ -1974,6 +2083,21 @@ class Guild(Hashable): |
|
|
if premium_progress_bar_enabled is not MISSING: |
|
|
if premium_progress_bar_enabled is not MISSING: |
|
|
fields['premium_progress_bar_enabled'] = premium_progress_bar_enabled |
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
if mfa_level is not MISSING: |
|
|
|
|
|
if not isinstance(mfa_level, MFALevel): |
|
|
|
|
|
raise TypeError(f'mfa_level must be of type MFALevel not {mfa_level.__class__.__name__}') |
|
|
|
|
|
|
|
|
|
|
|
await http.edit_guild_mfa_level(self.id, mfa_level=mfa_level.value) |
|
|
|
|
|
|
|
|
data = await http.edit_guild(self.id, reason=reason, **fields) |
|
|
data = await http.edit_guild(self.id, reason=reason, **fields) |
|
|
return Guild(data=data, state=self._state) |
|
|
return Guild(data=data, state=self._state) |
|
|
|
|
|
|
|
@ -2783,7 +2907,7 @@ class Guild(Hashable): |
|
|
|
|
|
|
|
|
Parameters |
|
|
Parameters |
|
|
------------ |
|
|
------------ |
|
|
id: :class:`int` |
|
|
scheduled_event_id: :class:`int` |
|
|
The scheduled event ID. |
|
|
The scheduled event ID. |
|
|
with_counts: :class:`bool` |
|
|
with_counts: :class:`bool` |
|
|
Whether to include the number of users that are subscribed to the event. |
|
|
Whether to include the number of users that are subscribed to the event. |
|
@ -2804,6 +2928,68 @@ class Guild(Hashable): |
|
|
data = await self._state.http.get_scheduled_event(self.id, scheduled_event_id, with_counts) |
|
|
data = await self._state.http.get_scheduled_event(self.id, scheduled_event_id, with_counts) |
|
|
return ScheduledEvent(state=self._state, data=data) |
|
|
return ScheduledEvent(state=self._state, data=data) |
|
|
|
|
|
|
|
|
|
|
|
@overload |
|
|
|
|
|
async def create_scheduled_event( |
|
|
|
|
|
self, |
|
|
|
|
|
*, |
|
|
|
|
|
name: str, |
|
|
|
|
|
start_time: datetime.datetime, |
|
|
|
|
|
entity_type: Literal[EntityType.external] = ..., |
|
|
|
|
|
privacy_level: PrivacyLevel = ..., |
|
|
|
|
|
location: str = ..., |
|
|
|
|
|
end_time: datetime.datetime = ..., |
|
|
|
|
|
description: str = ..., |
|
|
|
|
|
image: bytes = ..., |
|
|
|
|
|
reason: Optional[str] = ..., |
|
|
|
|
|
) -> ScheduledEvent: |
|
|
|
|
|
... |
|
|
|
|
|
|
|
|
|
|
|
@overload |
|
|
|
|
|
async def create_scheduled_event( |
|
|
|
|
|
self, |
|
|
|
|
|
*, |
|
|
|
|
|
name: str, |
|
|
|
|
|
start_time: datetime.datetime, |
|
|
|
|
|
entity_type: Literal[EntityType.stage_instance, EntityType.voice] = ..., |
|
|
|
|
|
privacy_level: PrivacyLevel = ..., |
|
|
|
|
|
channel: Snowflake = ..., |
|
|
|
|
|
end_time: datetime.datetime = ..., |
|
|
|
|
|
description: str = ..., |
|
|
|
|
|
image: bytes = ..., |
|
|
|
|
|
reason: Optional[str] = ..., |
|
|
|
|
|
) -> ScheduledEvent: |
|
|
|
|
|
... |
|
|
|
|
|
|
|
|
|
|
|
@overload |
|
|
|
|
|
async def create_scheduled_event( |
|
|
|
|
|
self, |
|
|
|
|
|
*, |
|
|
|
|
|
name: str, |
|
|
|
|
|
start_time: datetime.datetime, |
|
|
|
|
|
privacy_level: PrivacyLevel = ..., |
|
|
|
|
|
location: str = ..., |
|
|
|
|
|
end_time: datetime.datetime = ..., |
|
|
|
|
|
description: str = ..., |
|
|
|
|
|
image: bytes = ..., |
|
|
|
|
|
reason: Optional[str] = ..., |
|
|
|
|
|
) -> ScheduledEvent: |
|
|
|
|
|
... |
|
|
|
|
|
|
|
|
|
|
|
@overload |
|
|
|
|
|
async def create_scheduled_event( |
|
|
|
|
|
self, |
|
|
|
|
|
*, |
|
|
|
|
|
name: str, |
|
|
|
|
|
start_time: datetime.datetime, |
|
|
|
|
|
privacy_level: PrivacyLevel = ..., |
|
|
|
|
|
channel: Union[VoiceChannel, StageChannel] = ..., |
|
|
|
|
|
end_time: datetime.datetime = ..., |
|
|
|
|
|
description: str = ..., |
|
|
|
|
|
image: bytes = ..., |
|
|
|
|
|
reason: Optional[str] = ..., |
|
|
|
|
|
) -> ScheduledEvent: |
|
|
|
|
|
... |
|
|
|
|
|
|
|
|
async def create_scheduled_event( |
|
|
async def create_scheduled_event( |
|
|
self, |
|
|
self, |
|
|
*, |
|
|
*, |
|
@ -2847,6 +3033,8 @@ class Guild(Hashable): |
|
|
datetime object. Consider using :func:`utils.utcnow`. |
|
|
datetime object. Consider using :func:`utils.utcnow`. |
|
|
|
|
|
|
|
|
Required if the entity type is :attr:`EntityType.external`. |
|
|
Required if the entity type is :attr:`EntityType.external`. |
|
|
|
|
|
privacy_level: :class:`PrivacyLevel` |
|
|
|
|
|
The privacy level of the scheduled event. |
|
|
entity_type: :class:`EntityType` |
|
|
entity_type: :class:`EntityType` |
|
|
The entity type of the scheduled event. If the channel is a |
|
|
The entity type of the scheduled event. If the channel is a |
|
|
:class:`StageInstance` or :class:`VoiceChannel` then this is |
|
|
:class:`StageInstance` or :class:`VoiceChannel` then this is |
|
@ -2894,27 +3082,32 @@ class Guild(Hashable): |
|
|
) |
|
|
) |
|
|
payload['scheduled_start_time'] = start_time.isoformat() |
|
|
payload['scheduled_start_time'] = start_time.isoformat() |
|
|
|
|
|
|
|
|
|
|
|
entity_type = entity_type or getattr(channel, '_scheduled_event_entity_type', MISSING) |
|
|
if entity_type is MISSING: |
|
|
if entity_type is MISSING: |
|
|
if channel is MISSING: |
|
|
if channel and isinstance(channel, Object): |
|
|
|
|
|
if channel.type is VoiceChannel: |
|
|
|
|
|
entity_type = EntityType.voice |
|
|
|
|
|
elif channel.type is StageChannel: |
|
|
|
|
|
entity_type = EntityType.stage_instance |
|
|
|
|
|
|
|
|
|
|
|
elif location not in (MISSING, None): |
|
|
entity_type = EntityType.external |
|
|
entity_type = EntityType.external |
|
|
else: |
|
|
else: |
|
|
_entity_type = getattr(channel, '_scheduled_event_entity_type', MISSING) |
|
|
if not isinstance(entity_type, EntityType): |
|
|
if _entity_type is None: |
|
|
raise TypeError('entity_type must be of type EntityType') |
|
|
raise TypeError( |
|
|
|
|
|
'invalid GuildChannel type passed, must be VoiceChannel or StageChannel ' |
|
|
|
|
|
f'not {channel.__class__.__name__}' |
|
|
|
|
|
) |
|
|
|
|
|
if _entity_type is MISSING: |
|
|
|
|
|
raise TypeError('entity_type must be passed in when passing an ambiguous channel type') |
|
|
|
|
|
|
|
|
|
|
|
entity_type = _entity_type |
|
|
payload['entity_type'] = entity_type.value |
|
|
|
|
|
|
|
|
if not isinstance(entity_type, EntityType): |
|
|
if entity_type is None: |
|
|
raise TypeError('entity_type must be of type EntityType') |
|
|
raise TypeError( |
|
|
|
|
|
'invalid GuildChannel type passed, must be VoiceChannel or StageChannel ' f'not {channel.__class__.__name__}' |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
payload['entity_type'] = entity_type.value |
|
|
if privacy_level is not MISSING: |
|
|
|
|
|
if not isinstance(privacy_level, PrivacyLevel): |
|
|
|
|
|
raise TypeError('privacy_level must be of type PrivacyLevel.') |
|
|
|
|
|
|
|
|
payload['privacy_level'] = PrivacyLevel.guild_only.value |
|
|
payload['privacy_level'] = privacy_level.value |
|
|
|
|
|
|
|
|
if description is not MISSING: |
|
|
if description is not MISSING: |
|
|
payload['description'] = description |
|
|
payload['description'] = description |
|
@ -2924,7 +3117,7 @@ class Guild(Hashable): |
|
|
payload['image'] = image_as_str |
|
|
payload['image'] = image_as_str |
|
|
|
|
|
|
|
|
if entity_type in (EntityType.stage_instance, EntityType.voice): |
|
|
if entity_type in (EntityType.stage_instance, EntityType.voice): |
|
|
if channel is MISSING or channel is None: |
|
|
if channel in (MISSING, None): |
|
|
raise TypeError('channel must be set when entity_type is voice or stage_instance') |
|
|
raise TypeError('channel must be set when entity_type is voice or stage_instance') |
|
|
|
|
|
|
|
|
payload['channel_id'] = channel.id |
|
|
payload['channel_id'] = channel.id |
|
@ -2940,12 +3133,15 @@ class Guild(Hashable): |
|
|
|
|
|
|
|
|
metadata['location'] = location |
|
|
metadata['location'] = location |
|
|
|
|
|
|
|
|
if end_time is not MISSING: |
|
|
if end_time in (MISSING, None): |
|
|
if end_time.tzinfo is None: |
|
|
raise TypeError('end_time must be set when entity_type is external') |
|
|
raise ValueError( |
|
|
|
|
|
'end_time must be an aware datetime. Consider using discord.utils.utcnow() or datetime.datetime.now().astimezone() for local time.' |
|
|
if end_time not in (MISSING, None): |
|
|
) |
|
|
if end_time.tzinfo is None: |
|
|
payload['scheduled_end_time'] = end_time.isoformat() |
|
|
raise ValueError( |
|
|
|
|
|
'end_time must be an aware datetime. Consider using discord.utils.utcnow() or datetime.datetime.now().astimezone() for local time.' |
|
|
|
|
|
) |
|
|
|
|
|
payload['scheduled_end_time'] = end_time.isoformat() |
|
|
|
|
|
|
|
|
if metadata: |
|
|
if metadata: |
|
|
payload['entity_metadata'] = metadata |
|
|
payload['entity_metadata'] = metadata |
|
@ -3631,7 +3827,7 @@ class Guild(Hashable): |
|
|
if limit is not None: |
|
|
if limit is not None: |
|
|
limit -= len(entries) |
|
|
limit -= len(entries) |
|
|
|
|
|
|
|
|
after = Object(id=int(entries[0]['id'])) |
|
|
after = Object(id=int(entries[-1]['id'])) |
|
|
|
|
|
|
|
|
return data, entries, after, limit |
|
|
return data, entries, after, limit |
|
|
|
|
|
|
|
@ -3648,20 +3844,19 @@ class Guild(Hashable): |
|
|
if isinstance(after, datetime.datetime): |
|
|
if isinstance(after, datetime.datetime): |
|
|
after = Object(id=utils.time_snowflake(after, high=True)) |
|
|
after = Object(id=utils.time_snowflake(after, high=True)) |
|
|
|
|
|
|
|
|
if oldest_first is MISSING: |
|
|
if oldest_first: |
|
|
reverse = after is not MISSING |
|
|
if after is MISSING: |
|
|
else: |
|
|
after = OLDEST_OBJECT |
|
|
reverse = oldest_first |
|
|
|
|
|
|
|
|
|
|
|
predicate = None |
|
|
predicate = None |
|
|
|
|
|
|
|
|
if reverse: |
|
|
if oldest_first: |
|
|
strategy, state = _after_strategy, after |
|
|
strategy, state = _after_strategy, after |
|
|
if before: |
|
|
if before: |
|
|
predicate = lambda m: int(m['id']) < before.id |
|
|
predicate = lambda m: int(m['id']) < before.id |
|
|
else: |
|
|
else: |
|
|
strategy, state = _before_strategy, before |
|
|
strategy, state = _before_strategy, before |
|
|
if after and after != OLDEST_OBJECT: |
|
|
if after: |
|
|
predicate = lambda m: int(m['id']) > after.id |
|
|
predicate = lambda m: int(m['id']) > after.id |
|
|
|
|
|
|
|
|
# avoid circular import |
|
|
# avoid circular import |
|
@ -3674,8 +3869,6 @@ class Guild(Hashable): |
|
|
|
|
|
|
|
|
data, raw_entries, state, limit = await strategy(retrieve, state, limit) |
|
|
data, raw_entries, state, limit = await strategy(retrieve, state, limit) |
|
|
|
|
|
|
|
|
if reverse: |
|
|
|
|
|
raw_entries = reversed(raw_entries) |
|
|
|
|
|
if predicate: |
|
|
if predicate: |
|
|
raw_entries = filter(predicate, raw_entries) |
|
|
raw_entries = filter(predicate, raw_entries) |
|
|
|
|
|
|
|
@ -3748,7 +3941,7 @@ class Guild(Hashable): |
|
|
) -> None: |
|
|
) -> None: |
|
|
"""|coro| |
|
|
"""|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. |
|
|
You must have :attr:`~Permissions.manage_guild` to do this. |
|
|
|
|
|
|
|
@ -3776,7 +3969,8 @@ class Guild(Hashable): |
|
|
if enabled is not MISSING: |
|
|
if enabled is not MISSING: |
|
|
payload['enabled'] = enabled |
|
|
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 chunk(self, *, cache: bool = True) -> List[Member]: |
|
|
async def chunk(self, *, cache: bool = True) -> List[Member]: |
|
|
"""|coro| |
|
|
"""|coro| |
|
@ -3968,7 +4162,7 @@ class Guild(Hashable): |
|
|
event_type: AutoModRuleEventType, |
|
|
event_type: AutoModRuleEventType, |
|
|
trigger: AutoModTrigger, |
|
|
trigger: AutoModTrigger, |
|
|
actions: List[AutoModRuleAction], |
|
|
actions: List[AutoModRuleAction], |
|
|
enabled: bool = MISSING, |
|
|
enabled: bool = False, |
|
|
exempt_roles: Sequence[Snowflake] = MISSING, |
|
|
exempt_roles: Sequence[Snowflake] = MISSING, |
|
|
exempt_channels: Sequence[Snowflake] = MISSING, |
|
|
exempt_channels: Sequence[Snowflake] = MISSING, |
|
|
reason: str = MISSING, |
|
|
reason: str = MISSING, |
|
@ -3993,7 +4187,7 @@ class Guild(Hashable): |
|
|
The actions that will be taken when the automod rule is triggered. |
|
|
The actions that will be taken when the automod rule is triggered. |
|
|
enabled: :class:`bool` |
|
|
enabled: :class:`bool` |
|
|
Whether the automod rule is enabled. |
|
|
Whether the automod rule is enabled. |
|
|
Discord will default to ``False``. |
|
|
Defaults to ``False``. |
|
|
exempt_roles: Sequence[:class:`abc.Snowflake`] |
|
|
exempt_roles: Sequence[:class:`abc.Snowflake`] |
|
|
A list of roles that will be exempt from the automod rule. |
|
|
A list of roles that will be exempt from the automod rule. |
|
|
exempt_channels: Sequence[:class:`abc.Snowflake`] |
|
|
exempt_channels: Sequence[:class:`abc.Snowflake`] |
|
|