fix conflicts

This commit is contained in:
iDutchy
2021-05-02 21:05:05 -05:00
84 changed files with 2683 additions and 706 deletions

View File

@@ -3,7 +3,7 @@
"""
The MIT License (MIT)
Copyright (c) 2015-2020 Rapptz
Copyright (c) 2015-present Rapptz
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -95,7 +95,7 @@ class Guild(Hashable):
The guild owner's ID. Use :attr:`Guild.owner` instead.
unavailable: :class:`bool`
Indicates if the guild is unavailable. If this is ``True`` then the
reliability of other attributes outside of :meth:`Guild.id` is slim and they might
reliability of other attributes outside of :attr:`Guild.id` is slim and they might
all be ``None``. It is best to not do anything with the guild if it is unavailable.
Check the :func:`on_guild_unavailable` and :func:`on_guild_available` events.
@@ -205,7 +205,7 @@ class Guild(Hashable):
self._members.pop(member.id, None)
def __str__(self):
return self.name
return self.name or ''
def __int__(self):
return self.id
@@ -374,6 +374,18 @@ class Guild(Hashable):
r.sort(key=lambda c: (c.position, c.id))
return r
@property
def stage_channels(self):
"""List[:class:`StageChannel`]: A list of voice channels that belongs to this guild.
.. versionadded:: 1.7
This is sorted by the position and are in UI order from top to bottom.
"""
r = [ch for ch in self._channels.values() if isinstance(ch, StageChannel)]
r.sort(key=lambda c: (c.position, c.id))
return r
@property
def me(self):
""":class:`Member`: Similar to :attr:`Client.user` except an instance of :class:`Member`.
@@ -861,6 +873,13 @@ class Guild(Hashable):
except KeyError:
pass
try:
rtc_region = options.pop('rtc_region')
except KeyError:
pass
else:
options['rtc_region'] = None if rtc_region is None else str(rtc_region)
parent_id = category.id if category else None
return self._state.http.create_channel(self.id, channel_type.value, name=name, parent_id=parent_id,
permission_overwrites=perms, **options)
@@ -962,6 +981,11 @@ class Guild(Hashable):
The channel's preferred audio bitrate in bits per second.
user_limit: :class:`int`
The channel's limit for number of members that can be in a voice channel.
rtc_region: Optional[:class:`VoiceRegion`]
The region for the voice channel's voice communication.
A value of ``None`` indicates automatic voice region detection.
.. versionadded:: 1.7
Raises
------
@@ -984,6 +1008,38 @@ class Guild(Hashable):
self._channels[channel.id] = channel
return channel
async def create_stage_channel(self, name, *, topic=None, category=None, overwrites=None, reason=None, position=None):
"""|coro|
This is similar to :meth:`create_text_channel` except makes a :class:`StageChannel` instead.
.. note::
The ``slowmode_delay`` and ``nsfw`` parameters are not supported in this function.
.. versionadded:: 1.7
Raises
------
Forbidden
You do not have the proper permissions to create this channel.
HTTPException
Creating the channel failed.
InvalidArgument
The permission overwrite information is not in proper form.
Returns
-------
:class:`StageChannel`
The channel that was just created.
"""
data = await self._create_channel(name, overwrites, ChannelType.stage_voice, category, reason=reason, position=position, topic=topic)
channel = StageChannel(state=self._state, guild=self, data=data)
# temporarily add to the cache
self._channels[channel.id] = channel
return channel
async def create_category(self, name, *, overwrites=None, reason=None, position=None):
"""|coro|
@@ -1069,8 +1125,8 @@ class Guild(Hashable):
The new description of the guild. This is only available to guilds that
contain ``PUBLIC`` in :attr:`Guild.features`.
icon: :class:`bytes`
A :term:`py:bytes-like object` representing the icon. Only PNG/JPEG supported
and GIF This is only available to guilds that contain ``ANIMATED_ICON`` in :attr:`Guild.features`.
A :term:`py:bytes-like object` representing the icon. Only PNG/JPEG is supported.
GIF is only available to guilds that contain ``ANIMATED_ICON`` in :attr:`Guild.features`.
Could be ``None`` to denote removal of the icon.
banner: :class:`bytes`
A :term:`py:bytes-like object` representing the banner.
@@ -1270,7 +1326,7 @@ class Guild(Hashable):
def convert(d):
factory, ch_type = _channel_factory(d['type'])
if factory is None:
raise InvalidData('Unknown channel type {type} for channel ID {id}.'.format_map(data))
raise InvalidData('Unknown channel type {type} for channel ID {id}.'.format_map(d))
channel = factory(guild=self, state=self._state, data=d)
return channel
@@ -1278,9 +1334,7 @@ class Guild(Hashable):
return [convert(d) for d in data]
def fetch_members(self, *, limit=1000, after=None):
"""|coro|
Retrieves an :class:`.AsyncIterator` that enables receiving the guild's members. In order to use this,
"""Retrieves an :class:`.AsyncIterator` that enables receiving the guild's members. In order to use this,
:meth:`Intents.members` must be enabled.
.. note::
@@ -1370,11 +1424,11 @@ class Guild(Hashable):
async def fetch_member(self, member_id):
"""|coro|
Retreives a :class:`Member` from a guild ID, and a member ID.
Retrieves a :class:`Member` from a guild ID, and a member ID.
.. note::
This method is an API call. For general usage, consider :meth:`get_member` instead.
This method is an API call. If you have :attr:`Intents.members` and member cache enabled, consider :meth:`get_member` instead.
Parameters
-----------
@@ -1399,9 +1453,7 @@ class Guild(Hashable):
async def fetch_ban(self, user):
"""|coro|
Retrieves the :class:`BanEntry` for a user, which is a namedtuple
with a ``user`` and ``reason`` field. See :meth:`bans` for more
information.
Retrieves the :class:`BanEntry` for a user.
You must have the :attr:`~Permissions.ban_members` permission
to get this information.
@@ -1422,8 +1474,8 @@ class Guild(Hashable):
Returns
-------
BanEntry
The BanEntry object for the specified user.
:class:`BanEntry`
The :class:`BanEntry` object for the specified user.
"""
data = await self._state.http.get_ban(user.id, self.id)
return BanEntry(
@@ -1434,12 +1486,7 @@ class Guild(Hashable):
async def bans(self):
"""|coro|
Retrieves all the users that are banned from the guild.
This coroutine returns a :class:`list` of BanEntry objects, which is a
namedtuple with a ``user`` field to denote the :class:`User`
that got banned along with a ``reason`` field specifying
why the user was banned that could be set to ``None``.
Retrieves all the users that are banned from the guild as a :class:`list` of :class:`BanEntry`.
You must have the :attr:`~Permissions.ban_members` permission
to get this information.
@@ -1453,8 +1500,8 @@ class Guild(Hashable):
Returns
--------
List[BanEntry]
A list of BanEntry objects.
List[:class:`BanEntry`]
A list of :class:`BanEntry` objects.
"""
data = await self._state.http.get_bans(self.id)
@@ -1521,6 +1568,29 @@ class Guild(Hashable):
data = await self._state.http.prune_members(self.id, days, compute_prune_count=compute_prune_count, roles=roles, reason=reason)
return data['pruned']
async def templates(self):
"""|coro|
Gets the list of templates from this guild.
Requires :attr:`~.Permissions.manage_guild` permissions.
.. versionadded:: 1.7
Raises
-------
Forbidden
You don't have permissions to get the templates.
Returns
--------
List[:class:`Template`]
The templates for this guild.
"""
from .template import Template
data = await self._state.http.guild_templates(self.id)
return [Template(data=d, state=self._state) for d in data]
async def webhooks(self):
"""|coro|
@@ -1543,7 +1613,7 @@ class Guild(Hashable):
data = await self._state.http.guild_webhooks(self.id)
return [Webhook.from_state(d, state=self._state) for d in data]
async def estimate_pruned_members(self, *, days):
async def estimate_pruned_members(self, *, days, roles=None):
"""|coro|
Similar to :meth:`prune_members` except instead of actually
@@ -1554,6 +1624,11 @@ class Guild(Hashable):
-----------
days: :class:`int`
The number of days before counting as inactive.
roles: Optional[List[:class:`abc.Snowflake`]]
A list of :class:`abc.Snowflake` that represent roles to include in the estimate. If a member
has a role that is not specified, they'll be excluded.
.. versionadded:: 1.7
Raises
-------
@@ -1573,7 +1648,10 @@ class Guild(Hashable):
if not isinstance(days, int):
raise InvalidArgument('Expected int for ``days``, received {0.__class__.__name__} instead.'.format(days))
data = await self._state.http.estimate_pruned_members(self.id, days)
if roles:
roles = [str(role.id) for role in roles]
data = await self._state.http.estimate_pruned_members(self.id, days, roles)
return data['pruned']
async def invites(self):
@@ -1607,6 +1685,36 @@ class Guild(Hashable):
return result
async def create_template(self, *, name, description=None):
"""|coro|
Creates a template for the guild.
You must have the :attr:`~Permissions.manage_guild` permission to
do this.
.. versionadded:: 1.7
Parameters
-----------
name: :class:`str`
The name of the template.
description: Optional[:class:`str`]
The description of the template.
"""
from .template import Template
payload = {
'name': name
}
if description:
payload['description'] = description
data = await self._state.http.create_template(self.id, payload)
return Template(state=self._state, data=data)
async def create_integration(self, *, type, id):
"""|coro|
@@ -1786,6 +1894,9 @@ class Guild(Hashable):
You must have the :attr:`~Permissions.manage_roles` permission to
do this.
.. versionchanged:: 1.6
Can now pass ``int`` to ``colour`` keyword-only parameter.
Parameters
-----------
name: :class:`str`
@@ -2031,6 +2142,7 @@ class Guild(Hashable):
payload['max_age'] = 0
return Invite(state=self._state, data=payload)
@utils.deprecated()
def ack(self):
"""|coro|
@@ -2038,6 +2150,8 @@ class Guild(Hashable):
The user must not be a bot user.
.. deprecated:: 1.7
Raises
-------
HTTPException
@@ -2162,7 +2276,8 @@ class Guild(Hashable):
if not self._state._intents.members:
raise ClientException('Intents.members must be enabled to use this.')
return await self._state.chunk_guild(self, cache=cache)
if not self._state.is_guild_evicted(self):
return await self._state.chunk_guild(self, cache=cache)
async def query_members(self, query=None, *, limit=5, user_ids=None, presences=False, cache=True):
"""|coro|
@@ -2224,6 +2339,9 @@ class Guild(Hashable):
if user_ids is not None and query is not None:
raise ValueError('Cannot pass both query and user_ids')
if user_ids is not None and not user_ids:
raise ValueError('user_ids must contain at least 1 value')
limit = min(100, limit or 5)
return await self._state.query_members(self, query=query, limit=limit, user_ids=user_ids, presences=presences, cache=cache)