68 Commits

Author SHA1 Message Date
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
4ae8e81660 [lint] Remove redundant exception variables
Use bare raise statement when reraising the exception that occured, and
remove unused exception variables.  Also remove a pointless exception
handler in discord.opus.
2018-11-24 22:17:57 -05:00
Hornwitser
a71b3b5fa0 [lint] Limit unneccessarily broad except clauses
Add exception qualifier(s) to bare except clauses swallowing exceptions.
2018-11-24 22:17:57 -05: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
Rapptz
3d03dbc451 Change internal role storage in Guild to a dict instead of a list.
This adds the following APIs:

* Guild.get_role

This removes the following APIs:

* Guild.role_hierarchy

To compensate for the removed APIs, Guild.roles is now a sorted list
based on hierarchy. The first element will always be the @everyone
role.

This speeds up access at the cost of some memory, theoretically.
2018-09-24 21:08:48 -04:00
Rapptz
0352c80a17 Add support for Discord's slow mode.
Adds the following:

* `slowmode_delay` for `TextChannel.edit`
* `slowmode_delay` attribute for `TextChannel`
2018-09-14 22:55:29 -04:00
BeatButton
a4d1599ce9 Change docstrings to raw-strings 2018-09-14 22:55:27 -04:00
Hornwitser
c8b49d37be [lint] Fix incorrect and inconsistent whitespace
Adjust whitespace to be consistent with the rest of the library.
2018-08-22 21:43:53 -04:00
Hornwitser
119c5a0618 [lint] Remove unused variables
Left over from various refactoring and rewrites.
2018-08-22 21:43:51 -04:00
Rapptz
c67d95327e Remove dead package references. 2018-06-10 18:16:40 -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
Steve C
0e945915b7 Fixes various documentation errors/inconsistencies
Mostly dealing with permissions, also fixes Raw Events inclusion.
2018-05-18 20:25:54 -04:00
Rapptz
0dafdedc65 abc.GuildChannel.set_permissions can raise NotFound.
Fix #1254
2018-05-18 20:17:49 -04:00
Tobotimus
3112e1c17e Add intersphinx 2018-01-06 17:23:59 -05:00
Rapptz
f86ac47b28 Don't use Bulk Channel Edit endpoint if not actually moving channels.
Should make the category-only edit cases more straightforward since
it does not rely on other guilds in the cache, outside of the category
itself.
2017-09-24 04:55:10 -04:00
Rapptz
458cb83b47 Properly handle cases where a category is removed. 2017-09-21 22:15:47 -04:00
Steve C
233c2d80ef Fix grammar in abc docs, add new implementation 2017-09-13 13:54:09 -04:00
Rapptz
53b4890435 Add category support.
This adds:

* CategoryChannel, which represents a category
* Guild.by_category() which traverses the channels grouping by category
* Guild.categories to get a list of categories
* abc.GuildChannel.category to get the category a channel belongs to
* sync_permissions keyword argument to abc.GuildChannel.edit to sync
  permissions with a pre-existing or new category
* category keyword argument to abc.GuildChannel.edit to move a channel
  to a category
2017-09-13 09:44:36 -04:00
Rapptz
63231ef033 Remove reason keyword argument from message deletion.
Apparently this is unsupported.

Affected functions include:

* abc.Messageable.send
* Message.delete
* TextChannel.delete_messages
* TextChannel.purge
2017-08-15 22:38:43 -04:00
SinisterRectus
8acf3d01ce Remove GuildChannel.is_default 2017-08-08 17:31:09 -04:00
Gorialis
1582116b72 Add documentation examples for AsyncIterator and change_presence. 2017-08-08 17:31:08 -04:00
Rapptz
c2544b9101 Handle everyone role having top priority in permission resolution.
In Discord, if the @everyone role has an explicit allow but a later
role has an explicit deny, the permission is denied rather than allowed
despite the fact that on Discord, allows have a higher priority than
denies.

This is because the @everyone role is supposed to be the first role to
be applied, while the rest could be applied in an aggregate fashion.

Fixes #630.
2017-07-07 17:53:38 -04:00
Rapptz
e0f02f1775 Rename AsyncIterator.get to next to prevent shadowing. 2017-07-04 10:45:38 -04:00
BeatButton
1be119cd45 Allow sending files list smaller than 2 elements in Messageable.send
The previous restriction was unwarranted.
2017-06-07 20:07:43 -04:00
Rapptz
3330a19f35 Support for sending a nonce. 2017-05-31 07:34:59 -04:00
Rapptz
64d09f3720 Force disconnect in abc.Connectable.connect.
Some cases of is_connected is not set so we need to force it to clear
it anyway.
2017-05-13 16:01:32 -04:00
Rapptz
b44bba6ee6 First pass at documentation reform. 2017-05-12 20:14:34 -04:00
Rapptz
be2e706b2a Rename abc.Callable to abc.Connectable. 2017-05-10 21:36:49 -04:00
Rapptz
dff6bcc745 Add support for audit log reasons.
Most routes now have a 'reason' keyword argument.
2017-05-07 03:08:06 -04:00
Rapptz
d24c2a09b6 Change some format usage to use %-formatting.
Minor speed increase when we're not doing excessive attribute
access or any type of formatting.
2017-05-04 06:04:55 -04:00
Rapptz
0ce781b37c Fix NameError in GuildChannel.changed_roles 2017-04-22 04:44:21 -04:00
Rapptz
f9c2ac9d25 Better handling of VOICE_SERVER_UPDATE.
This now sort of respects "Awaiting Endpoint..." waiting. I haven't
actually tested out this case since it's hard to get it. However this
new code does work with the regular connection flow.
2017-04-18 19:05:34 -04:00
Rapptz
3b1b26ffb1 Re-implement voice sending.
This is a complete redesign of the old voice code.

A list of major changes is as follows:

* The voice websocket will now automatically reconnect with
  exponential back-off just like the regular Client does.
* Removal of the stream player concept.
* Audio now gracefully pauses and resumes when a disconnect is found.
* Introduce a discord.AudioSource concept to abstract streams
* Flatten previous stream player functionality with the
  VoiceClient, e.g. player.stop() is now voice_client.stop()
* With the above re-coupling this means you no longer have to
  store players anywhere.
* The after function now requires a single parameter, the error,
  if any existed. This will typically be None.

A lot of this design is experimental.
2017-04-18 03:49:48 -04:00
Rapptz
bf2066278e Add support for multiple file attachments.
This is a breaking change. No longer does Messageable.send have a
filename keyword argument, instead this is all handled through the
discord.File model. To upload many files you must specify a list
of discord.File objects.
2017-04-08 03:33:21 -04:00
Rapptz
4ffded622a Removing acking on channels. 2017-03-18 11:52:18 -04:00
Rapptz
0321558dec Handle case when guild owner somehow doesn't exist in permissions_for 2017-03-15 23:13:28 -04:00
Rapptz
8daf411c72 Add Messageable.ack 2017-02-28 00:47:37 -05:00
Rapptz
cbbc75cd8d Move purge and delete_messages from Messageable.
This is a breaking change. Move these two to TextChannel since the
other things that implement Messageable cannot reliably do bulk delete
actions in their respective channels.
2017-02-26 21:16:20 -05:00
Rapptz
0e8b260d45 Fall back to single message delete in Messageable.purge
Also make it work on user accounts.

Fixes #456.
2017-02-23 00:23:40 -05:00
Rapptz
54f297c24f Fix NameError in GuildChannel.overwrites_for 2017-02-17 22:10:12 -05:00
Rapptz
8e654bd52a Add support for limit=None in Messageable.history.
Fixes #480.
2017-02-13 19:55:04 -05:00
Rapptz
2abdbc70c2 Implement utilities for AsyncIterator.
Closes #473.
2017-02-11 23:34:19 -05:00
Rapptz
274e6af0dd Fix support for instant invites. 2017-02-08 22:47:52 -05:00
Rapptz
e77012f4d9 Make all public is_ functions into methods instead of properties. 2017-01-29 20:53:17 -05:00
Rapptz
ff9f5749e1 Update copyright year to 2017. 2017-01-20 23:19:19 -05:00
Rapptz
f4cadaf0cc Fix bug with GuildChannel.edit and Role.edit with positions.
I did not update the HTTP code for these two methods.
2017-01-16 18:19:18 -05:00
Rapptz
92dd519b1a Remove _get_guild_id from Messageable ABC. 2017-01-14 19:22:26 -05:00
Rapptz
33450cd1b6 Fix documentation to properly use Messageable.send 2017-01-13 20:35:44 -05:00
Rapptz
b9b9d8c4d0 Fix NameError inside Messageable.get_message 2017-01-11 20:26:06 -05:00
Rapptz
06ca518459 Rename NoMoreMessages to NoMoreItems. 2017-01-11 19:53:48 -05:00