Browse Source

Deprecate non-bot methods

pull/6468/head
Nadir Chowdhury 4 years ago
committed by GitHub
parent
commit
427e387a2f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      discord/calls.py
  2. 11
      discord/channel.py
  3. 5
      discord/client.py
  4. 3
      discord/guild.py
  5. 6
      discord/message.py
  6. 9
      discord/relationship.py
  7. 52
      discord/user.py
  8. 16
      docs/api.rst

29
discord/calls.py

@ -36,6 +36,8 @@ class CallMessage:
This is only received in cases where the message type is equivalent to This is only received in cases where the message type is equivalent to
:attr:`MessageType.call`. :attr:`MessageType.call`.
.. deprecated:: 1.7
Attributes Attributes
----------- -----------
ended_timestamp: Optional[:class:`datetime.datetime`] ended_timestamp: Optional[:class:`datetime.datetime`]
@ -53,12 +55,18 @@ class CallMessage:
@property @property
def call_ended(self): def call_ended(self):
""":class:`bool`: Indicates if the call has ended.""" """:class:`bool`: Indicates if the call has ended.
.. deprecated:: 1.7
"""
return self.ended_timestamp is not None return self.ended_timestamp is not None
@property @property
def channel(self): def channel(self):
r""":class:`GroupChannel`\: The private channel associated with this message.""" r""":class:`GroupChannel`\: The private channel associated with this message.
.. deprecated:: 1.7
"""
return self.message.channel return self.message.channel
@property @property
@ -68,6 +76,8 @@ class CallMessage:
If the call has not ended then the current duration will If the call has not ended then the current duration will
be returned. be returned.
.. deprecated:: 1.7
Returns Returns
--------- ---------
:class:`datetime.timedelta` :class:`datetime.timedelta`
@ -83,6 +93,8 @@ class GroupCall:
This is accompanied with a :class:`CallMessage` denoting the information. This is accompanied with a :class:`CallMessage` denoting the information.
.. deprecated:: 1.7
Attributes Attributes
----------- -----------
call: :class:`CallMessage` call: :class:`CallMessage`
@ -122,7 +134,10 @@ class GroupCall:
@property @property
def connected(self): def connected(self):
"""List[:class:`User`]: A property that returns all users that are currently in this call.""" """List[:class:`User`]: A property that returns all users that are currently in this call.
.. deprecated:: 1.7
"""
ret = [u for u in self.channel.recipients if self.voice_state_for(u) is not None] ret = [u for u in self.channel.recipients if self.voice_state_for(u) is not None]
me = self.channel.me me = self.channel.me
if self.voice_state_for(me) is not None: if self.voice_state_for(me) is not None:
@ -132,15 +147,21 @@ class GroupCall:
@property @property
def channel(self): def channel(self):
r""":class:`GroupChannel`\: Returns the channel the group call is in.""" r""":class:`GroupChannel`\: Returns the channel the group call is in.
.. deprecated:: 1.7
"""
return self.call.channel return self.call.channel
@utils.deprecated()
def voice_state_for(self, user): def voice_state_for(self, user):
"""Retrieves the :class:`VoiceState` for a specified :class:`User`. """Retrieves the :class:`VoiceState` for a specified :class:`User`.
If the :class:`User` has no voice state then this function returns If the :class:`User` has no voice state then this function returns
``None``. ``None``.
.. deprecated:: 1.7
Parameters Parameters
------------ ------------
user: :class:`User` user: :class:`User`

11
discord/channel.py

@ -347,7 +347,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
bulk: :class:`bool` bulk: :class:`bool`
If ``True``, use bulk delete. Setting this to ``False`` is useful for mass-deleting If ``True``, use bulk delete. Setting this to ``False`` is useful for mass-deleting
a bot's own messages without :attr:`Permissions.manage_messages`. When ``True``, will a bot's own messages without :attr:`Permissions.manage_messages`. When ``True``, will
fall back to single delete if current account is a user bot, or if messages are fall back to single delete if current account is a user bot (now deprecated), or if messages are
older than two weeks. older than two weeks.
Raises Raises
@ -1274,6 +1274,7 @@ class GroupChannel(discord.abc.Messageable, Hashable):
return base return base
@utils.deprecated()
async def add_recipients(self, *recipients): async def add_recipients(self, *recipients):
r"""|coro| r"""|coro|
@ -1284,6 +1285,8 @@ class GroupChannel(discord.abc.Messageable, Hashable):
add a recipient to the group, you must have a relationship add a recipient to the group, you must have a relationship
with the user of type :attr:`RelationshipType.friend`. with the user of type :attr:`RelationshipType.friend`.
.. deprecated:: 1.7
Parameters Parameters
----------- -----------
\*recipients: :class:`User` \*recipients: :class:`User`
@ -1301,11 +1304,14 @@ class GroupChannel(discord.abc.Messageable, Hashable):
for recipient in recipients: for recipient in recipients:
await req(self.id, recipient.id) await req(self.id, recipient.id)
@utils.deprecated()
async def remove_recipients(self, *recipients): async def remove_recipients(self, *recipients):
r"""|coro| r"""|coro|
Removes recipients from this group. Removes recipients from this group.
.. deprecated:: 1.7
Parameters Parameters
----------- -----------
\*recipients: :class:`User` \*recipients: :class:`User`
@ -1323,11 +1329,14 @@ class GroupChannel(discord.abc.Messageable, Hashable):
for recipient in recipients: for recipient in recipients:
await req(self.id, recipient.id) await req(self.id, recipient.id)
@utils.deprecated()
async def edit(self, **fields): async def edit(self, **fields):
"""|coro| """|coro|
Edits the group. Edits the group.
.. deprecated:: 1.7
Parameters Parameters
----------- -----------
name: Optional[:class:`str`] name: Optional[:class:`str`]

5
discord/client.py

@ -495,6 +495,8 @@ class Client:
Keyword argument that specifies if the account logging on is a bot Keyword argument that specifies if the account logging on is a bot
token or not. token or not.
.. deprecated:: 1.7
Raises Raises
------ ------
:exc:`.LoginFailure` :exc:`.LoginFailure`
@ -1385,11 +1387,14 @@ class Client:
data = await self.http.get_user(user_id) data = await self.http.get_user(user_id)
return User(state=self._connection, data=data) return User(state=self._connection, data=data)
@utils.deprecated()
async def fetch_user_profile(self, user_id): async def fetch_user_profile(self, user_id):
"""|coro| """|coro|
Gets an arbitrary user's profile. Gets an arbitrary user's profile.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.

3
discord/guild.py

@ -1974,6 +1974,7 @@ class Guild(Hashable):
payload['max_age'] = 0 payload['max_age'] = 0
return Invite(state=self._state, data=payload) return Invite(state=self._state, data=payload)
@utils.deprecated()
def ack(self): def ack(self):
"""|coro| """|coro|
@ -1981,6 +1982,8 @@ class Guild(Hashable):
The user must not be a bot user. The user must not be a bot user.
.. deprecated:: 1.7
Raises Raises
------- -------
HTTPException HTTPException

6
discord/message.py

@ -415,6 +415,9 @@ class Message(Hashable):
call: Optional[:class:`CallMessage`] call: Optional[:class:`CallMessage`]
The call that the message refers to. This is only applicable to messages of type The call that the message refers to. This is only applicable to messages of type
:attr:`MessageType.call`. :attr:`MessageType.call`.
.. deprecated:: 1.7
reference: Optional[:class:`~discord.MessageReference`] reference: Optional[:class:`~discord.MessageReference`]
The message that this message references. This is only applicable to messages of The message that this message references. This is only applicable to messages of
type :attr:`MessageType.pins_add`, crossposted messages created by a type :attr:`MessageType.pins_add`, crossposted messages created by a
@ -1244,6 +1247,7 @@ class Message(Hashable):
""" """
await self._state.http.clear_reactions(self.channel.id, self.id) await self._state.http.clear_reactions(self.channel.id, self.id)
@utils.deprecated()
async def ack(self): async def ack(self):
"""|coro| """|coro|
@ -1251,6 +1255,8 @@ class Message(Hashable):
The user must not be a bot user. The user must not be a bot user.
.. deprecated:: 1.7
Raises Raises
------- -------
HTTPException HTTPException

9
discord/relationship.py

@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE.
""" """
from .enums import RelationshipType, try_enum from .enums import RelationshipType, try_enum
from . import utils
class Relationship: class Relationship:
"""Represents a relationship in Discord. """Represents a relationship in Discord.
@ -32,6 +33,8 @@ class Relationship:
A relationship is like a friendship, a person who is blocked, etc. A relationship is like a friendship, a person who is blocked, etc.
Only non-bot accounts can have relationships. Only non-bot accounts can have relationships.
.. deprecated:: 1.7
Attributes Attributes
----------- -----------
user: :class:`User` user: :class:`User`
@ -50,11 +53,14 @@ class Relationship:
def __repr__(self): def __repr__(self):
return '<Relationship user={0.user!r} type={0.type!r}>'.format(self) return '<Relationship user={0.user!r} type={0.type!r}>'.format(self)
@utils.deprecated()
async def delete(self): async def delete(self):
"""|coro| """|coro|
Deletes the relationship. Deletes the relationship.
.. deprecated:: 1.7
Raises Raises
------ ------
HTTPException HTTPException
@ -63,12 +69,15 @@ class Relationship:
await self._state.http.remove_relationship(self.user.id) await self._state.http.remove_relationship(self.user.id)
@utils.deprecated()
async def accept(self): async def accept(self):
"""|coro| """|coro|
Accepts the relationship request. e.g. accepting a Accepts the relationship request. e.g. accepting a
friend request. friend request.
.. deprecated:: 1.7
Raises Raises
------- -------
HTTPException HTTPException

52
discord/user.py

@ -33,6 +33,7 @@ from .enums import DefaultAvatar, RelationshipType, UserFlags, HypeSquadHouse, P
from .errors import ClientException from .errors import ClientException
from .colour import Colour from .colour import Colour
from .asset import Asset from .asset import Asset
from .utils import deprecated
class Profile(namedtuple('Profile', 'flags user mutual_guilds connected_accounts premium_since')): class Profile(namedtuple('Profile', 'flags user mutual_guilds connected_accounts premium_since')):
__slots__ = () __slots__ = ()
@ -321,14 +322,22 @@ class ClientUser(BaseUser):
Specifies if the user is a verified account. Specifies if the user is a verified account.
email: Optional[:class:`str`] email: Optional[:class:`str`]
The email the user used when registering. The email the user used when registering.
.. deprecated:: 1.7
locale: Optional[:class:`str`] locale: Optional[:class:`str`]
The IETF language tag used to identify the language the user is using. The IETF language tag used to identify the language the user is using.
mfa_enabled: :class:`bool` mfa_enabled: :class:`bool`
Specifies if the user has MFA turned on and working. Specifies if the user has MFA turned on and working.
premium: :class:`bool` premium: :class:`bool`
Specifies if the user is a premium user (e.g. has Discord Nitro). Specifies if the user is a premium user (e.g. has Discord Nitro).
.. deprecated:: 1.7
premium_type: Optional[:class:`PremiumType`] premium_type: Optional[:class:`PremiumType`]
Specifies the type of premium a user has (e.g. Nitro or Nitro Classic). Could be None if the user is not premium. Specifies the type of premium a user has (e.g. Nitro or Nitro Classic). Could be None if the user is not premium.
.. deprecated:: 1.7
""" """
__slots__ = BaseUser.__slots__ + \ __slots__ = BaseUser.__slots__ + \
('email', 'locale', '_flags', 'verified', 'mfa_enabled', ('email', 'locale', '_flags', 'verified', 'mfa_enabled',
@ -353,9 +362,12 @@ class ClientUser(BaseUser):
self.premium = data.get('premium', False) self.premium = data.get('premium', False)
self.premium_type = try_enum(PremiumType, data.get('premium_type', None)) self.premium_type = try_enum(PremiumType, data.get('premium_type', None))
@deprecated()
def get_relationship(self, user_id): def get_relationship(self, user_id):
"""Retrieves the :class:`Relationship` if applicable. """Retrieves the :class:`Relationship` if applicable.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -376,6 +388,8 @@ class ClientUser(BaseUser):
def relationships(self): def relationships(self):
"""List[:class:`User`]: Returns all the relationships that the user has. """List[:class:`User`]: Returns all the relationships that the user has.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -386,6 +400,8 @@ class ClientUser(BaseUser):
def friends(self): def friends(self):
r"""List[:class:`User`]: Returns all the users that the user is friends with. r"""List[:class:`User`]: Returns all the users that the user is friends with.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -396,6 +412,8 @@ class ClientUser(BaseUser):
def blocked(self): def blocked(self):
r"""List[:class:`User`]: Returns all the users that the user has blocked. r"""List[:class:`User`]: Returns all the users that the user has blocked.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -410,6 +428,10 @@ class ClientUser(BaseUser):
If a bot account is used then a password field is optional, If a bot account is used then a password field is optional,
otherwise it is required. otherwise it is required.
.. warning::
The user account-only fields are deprecated.
.. note:: .. note::
To upload an avatar, a :term:`py:bytes-like object` must be passed in that To upload an avatar, a :term:`py:bytes-like object` must be passed in that
@ -501,6 +523,7 @@ class ClientUser(BaseUser):
self._update(data) self._update(data)
@deprecated()
async def create_group(self, *recipients): async def create_group(self, *recipients):
r"""|coro| r"""|coro|
@ -508,6 +531,8 @@ class ClientUser(BaseUser):
provided. These recipients must be have a relationship provided. These recipients must be have a relationship
of type :attr:`RelationshipType.friend`. of type :attr:`RelationshipType.friend`.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -541,11 +566,14 @@ class ClientUser(BaseUser):
data = await self._state.http.start_group(self.id, users) data = await self._state.http.start_group(self.id, users)
return GroupChannel(me=self, data=data, state=self._state) return GroupChannel(me=self, data=data, state=self._state)
@deprecated()
async def edit_settings(self, **kwargs): async def edit_settings(self, **kwargs):
"""|coro| """|coro|
Edits the client user's settings. Edits the client user's settings.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -748,11 +776,14 @@ class User(BaseUser, discord.abc.Messageable):
""" """
return self._state.user.get_relationship(self.id) return self._state.user.get_relationship(self.id)
@deprecated()
async def mutual_friends(self): async def mutual_friends(self):
"""|coro| """|coro|
Gets all mutual friends of this user. Gets all mutual friends of this user.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -773,9 +804,12 @@ class User(BaseUser, discord.abc.Messageable):
mutuals = await state.http.get_mutual_friends(self.id) mutuals = await state.http.get_mutual_friends(self.id)
return [User(state=state, data=friend) for friend in mutuals] return [User(state=state, data=friend) for friend in mutuals]
@deprecated()
def is_friend(self): def is_friend(self):
""":class:`bool`: Checks if the user is your friend. """:class:`bool`: Checks if the user is your friend.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -785,9 +819,12 @@ class User(BaseUser, discord.abc.Messageable):
return False return False
return r.type is RelationshipType.friend return r.type is RelationshipType.friend
@deprecated()
def is_blocked(self): def is_blocked(self):
""":class:`bool`: Checks if the user is blocked. """:class:`bool`: Checks if the user is blocked.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -797,11 +834,14 @@ class User(BaseUser, discord.abc.Messageable):
return False return False
return r.type is RelationshipType.blocked return r.type is RelationshipType.blocked
@deprecated()
async def block(self): async def block(self):
"""|coro| """|coro|
Blocks the user. Blocks the user.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -816,11 +856,14 @@ class User(BaseUser, discord.abc.Messageable):
await self._state.http.add_relationship(self.id, type=RelationshipType.blocked.value) await self._state.http.add_relationship(self.id, type=RelationshipType.blocked.value)
@deprecated()
async def unblock(self): async def unblock(self):
"""|coro| """|coro|
Unblocks the user. Unblocks the user.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -834,11 +877,14 @@ class User(BaseUser, discord.abc.Messageable):
""" """
await self._state.http.remove_relationship(self.id) await self._state.http.remove_relationship(self.id)
@deprecated()
async def remove_friend(self): async def remove_friend(self):
"""|coro| """|coro|
Removes the user as a friend. Removes the user as a friend.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -852,11 +898,14 @@ class User(BaseUser, discord.abc.Messageable):
""" """
await self._state.http.remove_relationship(self.id) await self._state.http.remove_relationship(self.id)
@deprecated()
async def send_friend_request(self): async def send_friend_request(self):
"""|coro| """|coro|
Sends the user a friend request. Sends the user a friend request.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.
@ -870,11 +919,14 @@ class User(BaseUser, discord.abc.Messageable):
""" """
await self._state.http.send_friend_request(username=self.name, discriminator=self.discriminator) await self._state.http.send_friend_request(username=self.name, discriminator=self.discriminator)
@deprecated()
async def profile(self): async def profile(self):
"""|coro| """|coro|
Gets the user's profile. Gets the user's profile.
.. deprecated:: 1.7
.. note:: .. note::
This can only be used by non-bot accounts. This can only be used by non-bot accounts.

16
docs/api.rst

@ -894,6 +894,8 @@ to handle it, which defaults to print a traceback and ignoring the exception.
Called when a :class:`Relationship` is added or removed from the Called when a :class:`Relationship` is added or removed from the
:class:`ClientUser`. :class:`ClientUser`.
.. deprecated:: 1.7
:param relationship: The relationship that was added or removed. :param relationship: The relationship that was added or removed.
:type relationship: :class:`Relationship` :type relationship: :class:`Relationship`
@ -902,6 +904,8 @@ to handle it, which defaults to print a traceback and ignoring the exception.
Called when a :class:`Relationship` is updated, e.g. when you Called when a :class:`Relationship` is updated, e.g. when you
block a friend or a friendship is accepted. block a friend or a friendship is accepted.
.. deprecated:: 1.7
:param before: The previous relationship status. :param before: The previous relationship status.
:type before: :class:`Relationship` :type before: :class:`Relationship`
:param after: The updated relationship status. :param after: The updated relationship status.
@ -937,6 +941,8 @@ Profile
A namedtuple representing a user's Discord public profile. A namedtuple representing a user's Discord public profile.
.. deprecated:: 1.7
.. attribute:: user .. attribute:: user
The :class:`User` the profile belongs to. The :class:`User` the profile belongs to.
@ -1892,6 +1898,8 @@ of :class:`enum.Enum`.
Specifies the type of :class:`Relationship`. Specifies the type of :class:`Relationship`.
.. deprecated:: 1.7
.. note:: .. note::
This only applies to users, *not* bots. This only applies to users, *not* bots.
@ -1918,6 +1926,8 @@ of :class:`enum.Enum`.
Represents the options found in ``Settings > Privacy & Safety > Safe Direct Messaging`` Represents the options found in ``Settings > Privacy & Safety > Safe Direct Messaging``
in the Discord client. in the Discord client.
.. deprecated:: 1.7
.. note:: .. note::
This only applies to users, *not* bots. This only applies to users, *not* bots.
@ -1940,6 +1950,8 @@ of :class:`enum.Enum`.
Represents the options found in ``Settings > Privacy & Safety > Who Can Add You As A Friend`` Represents the options found in ``Settings > Privacy & Safety > Who Can Add You As A Friend``
in the Discord client. in the Discord client.
.. deprecated:: 1.7
.. note:: .. note::
This only applies to users, *not* bots. This only applies to users, *not* bots.
@ -1969,6 +1981,8 @@ of :class:`enum.Enum`.
Represents the user's Discord Nitro subscription type. Represents the user's Discord Nitro subscription type.
.. deprecated:: 1.7
.. note:: .. note::
This only applies to users, *not* bots. This only applies to users, *not* bots.
@ -1986,6 +2000,8 @@ of :class:`enum.Enum`.
Represents the theme synced across all Discord clients. Represents the theme synced across all Discord clients.
.. deprecated:: 1.7
.. note:: .. note::
This only applies to users, *not* bots. This only applies to users, *not* bots.

Loading…
Cancel
Save