Skip to content

Commit ef6c896

Browse files
authored
Remove bot-specific methods and undeprecate user-specific methods (#21)
- Removes all bot-only methods + functions - Undeprecates user-only functions - Removes all traces of bots and removes deprecation notes from docstrings TODO: - Remove traces of the is_bot attribute
1 parent 70bbe31 commit ef6c896

File tree

6 files changed

+15
-270
lines changed

6 files changed

+15
-270
lines changed

discord/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
__author__ = 'Rapptz'
1616
__license__ = 'MIT'
1717
__copyright__ = 'Copyright 2015-present Rapptz'
18-
__version__ = '1.7.7'
18+
__version__ = '1.7.8'
1919

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

@@ -62,6 +62,6 @@
6262

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

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

6767
logging.getLogger(__name__).addHandler(logging.NullHandler())

discord/abc.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,37 +1101,6 @@ def typing(self):
11011101
"""
11021102
return Typing(self)
11031103

1104-
async def fetch_message(self, id):
1105-
"""|coro|
1106-
1107-
Retrieves a single :class:`~discord.Message` from the destination.
1108-
1109-
This can only be used by bot accounts.
1110-
1111-
Parameters
1112-
------------
1113-
id: :class:`int`
1114-
The message ID to look for.
1115-
1116-
Raises
1117-
--------
1118-
~discord.NotFound
1119-
The specified message was not found.
1120-
~discord.Forbidden
1121-
You do not have the permissions required to get a message.
1122-
~discord.HTTPException
1123-
Retrieving the message failed.
1124-
1125-
Returns
1126-
--------
1127-
:class:`~discord.Message`
1128-
The message asked for.
1129-
"""
1130-
1131-
channel = await self._get_channel()
1132-
data = await self._state.http.get_message(channel.id, id)
1133-
return self._state.create_message(channel=channel, data=data)
1134-
11351104
async def pins(self):
11361105
"""|coro|
11371106

discord/channel.py

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,8 @@ def last_message(self):
174174
:class: helpful
175175
176176
For a slightly more reliable method of fetching the
177-
last message, consider using either :meth:`history`
178-
or :meth:`fetch_message` with the :attr:`last_message_id`
179-
attribute.
177+
last message, consider using :meth:`history`
178+
with the :attr:`last_message_id` attribute.
180179
181180
Returns
182181
---------
@@ -248,59 +247,7 @@ async def clone(self, *, name=None, reason=None):
248247
'rate_limit_per_user': self.slowmode_delay
249248
}, name=name, reason=reason)
250249

251-
async def delete_messages(self, messages):
252-
"""|coro|
253-
254-
Deletes a list of messages. This is similar to :meth:`Message.delete`
255-
except it bulk deletes multiple messages.
256-
257-
As a special case, if the number of messages is 0, then nothing
258-
is done. If the number of messages is 1 then single message
259-
delete is done. If it's more than two, then bulk delete is used.
260-
261-
You cannot bulk delete more than 100 messages or messages that
262-
are older than 14 days old.
263-
264-
You must have the :attr:`~Permissions.manage_messages` permission to
265-
use this.
266-
267-
Usable only by bot accounts.
268-
269-
Parameters
270-
-----------
271-
messages: Iterable[:class:`abc.Snowflake`]
272-
An iterable of messages denoting which ones to bulk delete.
273-
274-
Raises
275-
------
276-
ClientException
277-
The number of messages to delete was more than 100.
278-
Forbidden
279-
You do not have proper permissions to delete the messages or
280-
you're not using a bot account.
281-
NotFound
282-
If single delete, then the message was already deleted.
283-
HTTPException
284-
Deleting the messages failed.
285-
"""
286-
if not isinstance(messages, (list, tuple)):
287-
messages = list(messages)
288-
289-
if len(messages) == 0:
290-
return # do nothing
291-
292-
if len(messages) == 1:
293-
message_id = messages[0].id
294-
await self._state.http.delete_message(self.id, message_id)
295-
return
296-
297-
if len(messages) > 100:
298-
raise ClientException('Can only bulk delete messages up to 100 messages')
299-
300-
message_ids = [m.id for m in messages]
301-
await self._state.http.delete_messages(self.id, message_ids)
302-
303-
async def purge(self, *, limit=100, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True):
250+
async def purge(self, *, limit=100, check=None, before=None, after=None, around=None, oldest_first=False):
304251
"""|coro|
305252
306253
Purges a list of messages that meet the criteria given by the predicate
@@ -312,10 +259,6 @@ async def purge(self, *, limit=100, check=None, before=None, after=None, around=
312259
account). The :attr:`~Permissions.read_message_history` permission is
313260
also needed to retrieve message history.
314261
315-
Internally, this employs a different number of strategies depending
316-
on the conditions met such as if a bulk delete is possible or if
317-
the account is a user bot or not.
318-
319262
Examples
320263
---------
321264
@@ -343,11 +286,6 @@ def is_me(m):
343286
Same as ``around`` in :meth:`history`.
344287
oldest_first: Optional[:class:`bool`]
345288
Same as ``oldest_first`` in :meth:`history`.
346-
bulk: :class:`bool`
347-
If ``True``, use bulk delete. Setting this to ``False`` is useful for mass-deleting
348-
a bot's own messages without :attr:`Permissions.manage_messages`. When ``True``, will
349-
fall back to single delete if current account is a user bot (now deprecated), or if messages are
350-
older than two weeks.
351289
352290
Raises
353291
-------
@@ -370,7 +308,7 @@ def is_me(m):
370308
count = 0
371309

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

375313
while True:
376314
try:

discord/client.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,6 @@ async def login(self, token):
491491
token: :class:`str`
492492
The authentication token. Do not prefix this token with
493493
anything as the library will do it for you.
494-
bot: :class:`bool`
495-
Keyword argument that specifies if the account logging on is a bot
496-
token or not.
497-
498-
.. deprecated:: 1.7
499494
500495
Raises
501496
------
@@ -1192,8 +1187,6 @@ async def create_guild(self, name, region=None, icon=None, *, code=None):
11921187
11931188
Creates a :class:`.Guild`.
11941189
1195-
Bot accounts in more than 10 guilds are not allowed to create guilds.
1196-
11971190
Parameters
11981191
----------
11991192
name: :class:`str`
@@ -1351,50 +1344,11 @@ async def application_info(self):
13511344
data['rpc_origins'] = None
13521345
return AppInfo(self._connection, data)
13531346

1354-
async def fetch_user(self, user_id):
1355-
"""|coro|
1356-
1357-
Retrieves a :class:`~discord.User` based on their ID. This can only
1358-
be used by bot accounts. You do not have to share any guilds
1359-
with the user to get this information, however many operations
1360-
do require that you do.
1361-
1362-
.. note::
1363-
1364-
This method is an API call. If you have :attr:`Intents.members` and member cache enabled, consider :meth:`get_user` instead.
1365-
1366-
Parameters
1367-
-----------
1368-
user_id: :class:`int`
1369-
The user's ID to fetch from.
1370-
1371-
Raises
1372-
-------
1373-
:exc:`.NotFound`
1374-
A user with this ID does not exist.
1375-
:exc:`.HTTPException`
1376-
Fetching the user failed.
1377-
1378-
Returns
1379-
--------
1380-
:class:`~discord.User`
1381-
The user you requested.
1382-
"""
1383-
data = await self.http.get_user(user_id)
1384-
return User(state=self._connection, data=data)
1385-
1386-
@utils.deprecated()
13871347
async def fetch_user_profile(self, user_id):
13881348
"""|coro|
13891349
13901350
Gets an arbitrary user's profile.
13911351
1392-
.. deprecated:: 1.7
1393-
1394-
.. note::
1395-
1396-
This can only be used by non-bot accounts.
1397-
13981352
Parameters
13991353
------------
14001354
user_id: :class:`int`

discord/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ async def request(self, route, *, files=None, form=None, **kwargs):
148148
}
149149

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

0 commit comments

Comments
 (0)