78 Commits

Author SHA1 Message Date
khazhyk
366dc4855b simplify HistoryIterator message ordering
rename reverse -> oldest_first, which is more obvious what it does.
Then, honor it entirely - if you specify no `after` endpoint, we default
to the beginning of message history, similar to how `before` defaults to
the end of message history.

This is a breaking change, and will change the behavior of any iterator
that previously would have been returning messages in a weird order for
limits over 100

`for msg in history(reversed=True, limit=300)` would return the newest
300 messages, in a messed up order (100..0, 200..100, 300..200).
`for msg in history(oldest_first=True, limit=300)` will now return the
oldest 300 messages in order. And so on.

`for msg in history(after=msg)` is unchanged, this previously would
return the oldest 100 messages after `msg`, oldest->newest order, and
still will.
2019-04-07 22:46:40 -07:00
Rapptz
79183846dc Make abc.GuildChannel.overwrites return a dictionary
Fix #2016
2019-04-06 19:33:31 -04:00
Dice
8123d4a5f7 Add type checking to multi-file send
Convert list comprehension to genexpr
2019-03-20 09:22:08 -04:00
Dice
6f3e32cfbb Fix sending multiple files
Fixes #2002
2019-03-20 09:21:16 -04:00
NCPlayz
f507f508a2 Expose Metadata
Added access to:
* `/users/@me/guilds`
* `/guilds/{guild_id}`
* `/guilds/{guild_id}/members/{member_id}`

BREAKING CHANGE:
* `get_user_info` -> `fetch_user_info` to match naming scheme.

Remove useless note

Remove `reverse` and corresponding documentation

Update documentation to reflect #1988

Rename `get_` HTTP functions to `fetch_`

Breaking Changes:
* `get_message` -> `fetch_message`
* `get_invite` -> `fetch_invite`
* `get_user_profile` -> `fetch_user_profile`
* `get_webhook_info` -> `fetch_webhook`
* `get_ban` -> `fetch_ban`

Fix InviteConverter, update migrating.rst

Rename get_message to fetch_message
2019-03-19 09:00:18 -04:00
NCPlayz
fb02191b80 Organise documentation 2019-03-19 08:24:42 -04:00
Rapptz
5e65ec978c Take back ownership of files from aiohttp for retrying requests.
Fix #1809
2019-03-18 07:54:36 -04:00
Rapptz
5061915b2a Add support for store channels. 2019-03-17 14:32:51 -04:00
Rapptz
053e2f5b9a Fix documentation linking issue in Messageables and Context 2019-03-16 09:55:29 -04:00
Dante Dam
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -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
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