Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
__author__ = 'Rapptz'
__license__ = 'MIT'
__copyright__ = 'Copyright 2015-present Rapptz'
__version__ = '1.7.7'
__version__ = '1.7.8'

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

Expand Down Expand Up @@ -62,6 +62,6 @@

VersionInfo = namedtuple('VersionInfo', 'major minor micro releaselevel serial')

version_info = VersionInfo(major=1, minor=7, micro=7, releaselevel='final', serial=0)
version_info = VersionInfo(major=1, minor=7, micro=8, releaselevel='final', serial=0)

logging.getLogger(__name__).addHandler(logging.NullHandler())
31 changes: 0 additions & 31 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,37 +1101,6 @@ def typing(self):
"""
return Typing(self)

async def fetch_message(self, id):
"""|coro|

Retrieves a single :class:`~discord.Message` from the destination.

This can only be used by bot accounts.

Parameters
------------
id: :class:`int`
The message ID to look for.

Raises
--------
~discord.NotFound
The specified message was not found.
~discord.Forbidden
You do not have the permissions required to get a message.
~discord.HTTPException
Retrieving the message failed.

Returns
--------
:class:`~discord.Message`
The message asked for.
"""

channel = await self._get_channel()
data = await self._state.http.get_message(channel.id, id)
return self._state.create_message(channel=channel, data=data)

async def pins(self):
"""|coro|

Expand Down
70 changes: 4 additions & 66 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ def last_message(self):
:class: helpful

For a slightly more reliable method of fetching the
last message, consider using either :meth:`history`
or :meth:`fetch_message` with the :attr:`last_message_id`
attribute.
last message, consider using :meth:`history`
with the :attr:`last_message_id` attribute.

Returns
---------
Expand Down Expand Up @@ -248,59 +247,7 @@ async def clone(self, *, name=None, reason=None):
'rate_limit_per_user': self.slowmode_delay
}, name=name, reason=reason)

async def delete_messages(self, messages):
"""|coro|

Deletes a list of messages. This is similar to :meth:`Message.delete`
except it bulk deletes multiple messages.

As a special case, if the number of messages is 0, then nothing
is done. If the number of messages is 1 then single message
delete is done. If it's more than two, then bulk delete is used.

You cannot bulk delete more than 100 messages or messages that
are older than 14 days old.

You must have the :attr:`~Permissions.manage_messages` permission to
use this.

Usable only by bot accounts.

Parameters
-----------
messages: Iterable[:class:`abc.Snowflake`]
An iterable of messages denoting which ones to bulk delete.

Raises
------
ClientException
The number of messages to delete was more than 100.
Forbidden
You do not have proper permissions to delete the messages or
you're not using a bot account.
NotFound
If single delete, then the message was already deleted.
HTTPException
Deleting the messages failed.
"""
if not isinstance(messages, (list, tuple)):
messages = list(messages)

if len(messages) == 0:
return # do nothing

if len(messages) == 1:
message_id = messages[0].id
await self._state.http.delete_message(self.id, message_id)
return

if len(messages) > 100:
raise ClientException('Can only bulk delete messages up to 100 messages')

message_ids = [m.id for m in messages]
await self._state.http.delete_messages(self.id, message_ids)

async def purge(self, *, limit=100, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True):
async def purge(self, *, limit=100, check=None, before=None, after=None, around=None, oldest_first=False):
"""|coro|

Purges a list of messages that meet the criteria given by the predicate
Expand All @@ -312,10 +259,6 @@ async def purge(self, *, limit=100, check=None, before=None, after=None, around=
account). The :attr:`~Permissions.read_message_history` permission is
also needed to retrieve message history.

Internally, this employs a different number of strategies depending
on the conditions met such as if a bulk delete is possible or if
the account is a user bot or not.

Examples
---------

Expand Down Expand Up @@ -343,11 +286,6 @@ def is_me(m):
Same as ``around`` in :meth:`history`.
oldest_first: Optional[:class:`bool`]
Same as ``oldest_first`` in :meth:`history`.
bulk: :class:`bool`
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
fall back to single delete if current account is a user bot (now deprecated), or if messages are
older than two weeks.

Raises
-------
Expand All @@ -370,7 +308,7 @@ def is_me(m):
count = 0

minimum_time = int((time.time() - 14 * 24 * 60 * 60) * 1000.0 - 1420070400000) << 22
strategy = self.delete_messages if self._state.is_bot and bulk else _single_delete_strategy
strategy = _single_delete_strategy

while True:
try:
Expand Down
46 changes: 0 additions & 46 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,6 @@ async def login(self, token):
token: :class:`str`
The authentication token. Do not prefix this token with
anything as the library will do it for you.
bot: :class:`bool`
Keyword argument that specifies if the account logging on is a bot
token or not.

.. deprecated:: 1.7

Raises
------
Expand Down Expand Up @@ -1192,8 +1187,6 @@ async def create_guild(self, name, region=None, icon=None, *, code=None):

Creates a :class:`.Guild`.

Bot accounts in more than 10 guilds are not allowed to create guilds.

Parameters
----------
name: :class:`str`
Expand Down Expand Up @@ -1351,50 +1344,11 @@ async def application_info(self):
data['rpc_origins'] = None
return AppInfo(self._connection, data)

async def fetch_user(self, user_id):
"""|coro|

Retrieves a :class:`~discord.User` based on their ID. This can only
be used by bot accounts. You do not have to share any guilds
with the user to get this information, however many operations
do require that you do.

.. note::

This method is an API call. If you have :attr:`Intents.members` and member cache enabled, consider :meth:`get_user` instead.

Parameters
-----------
user_id: :class:`int`
The user's ID to fetch from.

Raises
-------
:exc:`.NotFound`
A user with this ID does not exist.
:exc:`.HTTPException`
Fetching the user failed.

Returns
--------
:class:`~discord.User`
The user you requested.
"""
data = await self.http.get_user(user_id)
return User(state=self._connection, data=data)

@utils.deprecated()
async def fetch_user_profile(self, user_id):
"""|coro|

Gets an arbitrary user's profile.

.. deprecated:: 1.7

.. note::

This can only be used by non-bot accounts.

Parameters
------------
user_id: :class:`int`
Expand Down
2 changes: 1 addition & 1 deletion discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async def request(self, route, *, files=None, form=None, **kwargs):
}

if self.token is not None:
headers['Authorization'] = 'Bot ' + self.token if self.bot_token else self.token
headers['Authorization'] = self.token
# some checking if it's a JSON request
if 'json' in kwargs:
headers['Content-Type'] = 'application/json'
Expand Down
Loading