87 Commits

Author SHA1 Message Date
NCPlayz
f09162f259 isinstance(x, y) and isinstance(x, z) -> isinstance(x, (y, z)) 2020-05-23 21:56:40 -04:00
Rapptz
66c6be50d8 Prepare for the discord.com domain rename 2020-05-23 21:44:30 -04:00
Rapptz
17f343b03e Minor documentation fixes 2020-01-21 21:34:58 -05:00
Rapptz
706a333287 Add missing coroutine header for sleep_until 2020-01-21 20:39:15 -05:00
Josh B
d0a1956be9 Improve usability of utils.sleep_until
Fix issue where sleeping for an extended period on python 3.5
would cause an exception

Add sleep_until to API docs

Add result argument to sleep_until
2020-01-21 20:28:14 -05:00
Rapptz
02397306b2 Drop superfluous zero in version related changes in the documentation 2020-01-21 03:47:56 -05:00
Josh B
40369a493d Add discord.utils.sleep_until helper function 2020-01-21 03:18:25 -05:00
Rapptz
6071607176 Bump copyright year to 2020
Closes #2510
2020-01-19 20:03:00 -05:00
alexandrianlibrarian
def012e281 Be more explicit in the utils.find example code. 2019-12-17 00:15:16 -05:00
Rapptz
4ef0fb0d95 Fix more deprecation warnings 2019-11-20 03:04:04 -05:00
Rapptz
a6f61dcbde Fix all deprecation warnings for 3.8 2019-11-20 02:30:19 -05:00
Rapptz
a238c6178a Update regex to fetch URLs to match the official client.
Fixes #2420.
2019-11-18 22:22:54 -05:00
Rapptz
ea3d119ca6 Use X-Ratelimit-Reset-After header by default.
There is now an option to turn it off, of course.
2019-08-27 18:41:32 -04:00
Rapptz
078d1d71d8 Use new rate limit millisecond precision option. 2019-08-27 18:41:31 -04:00
Rapptz
8e594ac1ad Escape quote markdown in utils.escape_markdown 2019-07-27 22:14:14 -04:00
Rapptz
5b2f630848 Add Guild.query_members to fetch members from the gateway. 2019-07-15 07:56:48 -04:00
NCPlayz
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
Rapptz
0622e18cb9 Speed-up utils.get for the common cases 2019-05-29 00:45:48 -04:00
khazhyk
b1fae0861a add read-only cached_messages property to Client
For those of us who want access to this sweet trove of zero hop messages
2019-04-17 22:41:59 -04:00
Rapptz
7b95611e62 Forgot to escape backticks. 2019-04-07 00:46:15 -04:00
Rapptz
4d06879669 Add ignore_links and as_needed options to utils.escape_markdown.
This allows for URLs to be left alone since they can include markdown
characters and allows for total escaping of all markdown characters
by default to prevent some form of data manipulation.
2019-04-07 00:24:34 -04:00
Rapptz
d68af294a2 Fix regex substitution in utils.escape_mentions 2019-04-06 23:02:49 -04:00
Rapptz
9833ea82e2 Add helpers to escape markdown and mentions from text.
Fixes #1673
2019-04-06 20:14:05 -04:00
NCPlayz
8a30a4cac0 Add support for guild widget 2019-03-19 09:22:48 -04:00
NCPlayz
fb02191b80 Organise documentation 2019-03-19 08:24:42 -04:00
SnowyLuma
42a7c4f7e5 Add support for guild banners
Document banner attribute of Guild and Invite

Update discord/utils.py

Co-Authored-By: SnowyLuma <38926001+SnowyLuma@users.noreply.github.com>
2019-03-09 00:37:49 -05:00
Rapptz
7d877e9067 Better jpeg detection in utils._get_mime_type_for_image
Fixes #1901
2019-02-23 10:25:05 -05:00
Rapptz
700dbb5555 Fix missing import. 2019-02-06 02:28:59 -05:00
Rapptz
e429763dea Try to optimize for the common ASCII case.
This is still a slowdown (about 45ns to 300ns) but it's less severe
than the original implementation (about 900 to 1100ns).
2019-02-06 02:15:22 -05:00
cod
d107f485a5 [commands] Fix ext.commands help page full-width indentation
add _string_width function to util. Changed string width calculate
function from len() to util function _string_width().
2019-02-06 02:15:04 -05:00
Dante Dam
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -05:00
Valentin
0614e2af90 Use a tuple for startswith in mime detection code. 2019-01-28 21:47:23 -05:00
khazhyk
c30b016bb5 Support webp in _get_mime_type_for_image
untested
2018-11-24 23:18:11 -05:00
Hornwitser
efb4ff850e [lint] Fix import order
Reorder imports to be consistenly grouped by standard library, third
party library, and local modules in that order thoughout the library.
2018-11-24 22:17:58 -05:00
Hornwitser
a0634b3eea [lint] Simplyfy util.valid_icon_size
Remove redundant paranthesis and checks from util.valid_icon_size.
2018-11-24 22:17:58 -05:00
Hornwitser
51d626eabe [lint] Remove redundant paranthesis
Remove redundant parenthisis around await expressions.  Left over from
f25091ef.
2018-11-24 22:17:58 -05:00
Matt (IPv4)
3727ea9811 Add Guild.splash_url_as 2018-10-11 02:38:52 -04:00
Rapptz
95d8bb2e85 Change internal representation of roles in Member and Emoji.
Introduce a new internal type, SnowflakeList, which has better memory
footprint over a regular list or set of roles. It is suspected that
there will be a 9x reduction of memory for every Emoji instance and a
48 byte saving per Member instance. However, these savings will
probably only be evident on larger bots.

As a consequence of this change, Member.roles is now computed lazily.

Currently I am not sure if I want to do the initial sorting on the
SnowflakeList for Member, as this comes with a O(n log n) cost when
creating a Member for little purpose since SnowflakeList.has is not
overly relied on. If CPU time becomes an issue this might change.
2018-09-24 22:19:42 -04:00
BeatButton
a4d1599ce9 Change docstrings to raw-strings 2018-09-14 22:55:27 -04:00
Hornwitser
119c5a0618 [lint] Remove unused variables
Left over from various refactoring and rewrites.
2018-08-22 21:43:51 -04:00
Rapptz
f25091efe1 Drop support for Python 3.4 and make minimum version 3.5.2. 2018-06-10 18:10:00 -04:00
ReinaSakuraba
d53cada91e Fix TypeError in utils.oauth_url 2017-10-04 21:27:31 -07:00
Rapptz
5e913b265b Change how coroutines are detected internally. 2017-09-16 13:35:00 -04:00
Rapptz
ede1771960 Fix utils.get example. 2017-08-30 01:37:25 -04:00
Rapptz
37b0fdb898 Add webhook support.
Allows for usage of either `requests` and `aiohttp` when used in
"Standalone" mode.

Fixes #704
2017-08-21 01:57:07 -04:00
khazhyk
0a588fac1c allow trailing null bytes in uploaded jpegs 2017-07-25 06:09:41 -04:00
khazhyk
12ca0d9b16 avatar_url_as improvements
static_format will only apply to static (not animated) avatars. Makes
it easier to grab gif-or-'format' of an avatar. Defaults to 'webp'

This is for a similar usecase to avatar_url_as(format=None), except
one can specify the non-animated format, instead of always using
webp.

add User.avatar_is_animated property.

add validation for avatar_url_as, since invalid arguments result in
a url which will return 415, which can be confusing for a user. (They
just see a blank page)

Discord accepts size=16-2048, but images cap at 1024px, so accept 16-1024
Discord accepts "jpg", "jpeg", "png", "gif", and "webp", *unless* the
avatar is not animated, in which case "gif" is not supported. :\
2017-07-25 06:09:40 -04:00
Rapptz
d239cc2666 Implement "partial" message events.
These are events that get triggered regardless of the state of the
message cache. Useful for getting data from before the bot was booted.
2017-06-09 18:36:59 -04:00
Rapptz
f588876587 Use Python3Lexer instead of PythonLexer for pygments. 2017-05-22 07:21:23 -04:00
Rapptz
1fc08bc5a2 Remove unused imports. 2017-04-18 04:22:35 -04:00