Commit Graph
100 Commits
Author SHA1 Message Date
Rapptz eb58ddffd8 Skip None action types when iterating. 2017-05-07 12:09:27 -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 2b44876955 Fix NameError when making things Object in audit logs. 2017-05-07 01:06:15 -04:00
Rapptz 7916878eb5 Audit log role add and removes are lists, not single item.
Breaking change. role -> roles and it's now a list.
2017-05-06 16:39:47 -04:00
Rapptz d7153b1b5c Replace hasattr with try except in chunker. 2017-05-05 21:45:51 -04:00
Rapptz 1626ade67d Split on_channel_pins_update as well. 2017-05-05 21:37:38 -04:00
Rapptz 322c70fda9 Rework some events to make more sense.
This is a breaking change.

1. Change on_guild_emojis_update to have 3 arguments.
    - The first parameter is now the guild object
2. Remove on_channel_create, on_channel_delete, and on_channel_update
	- They are now split into two.
	- on_guild_channel_[create|delete|update]
	- on_private_channel_[create|delete|update]
3. Change on_member_ban to allow User.
    - (member) -> (guild, user)
    - user can also be a Member
2017-05-05 20:47:25 -04:00
Rapptz c20ba51e28 [commands] Export is_nsfw check. 2017-05-05 20:21:28 -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 86bfcdd129 Add support for message delete audit log action type. 2017-05-04 04:35:02 -04:00
Rapptz 663315f7ac Explicitly close UDP sockets when re-creating them.
This does not actually make a big difference since the GC should
technically close them when needed but might as well be more explicit.
2017-05-02 20:25:54 -04:00
Rapptz fac43ad595 Fix NameError in HTTPClient.kick 2017-05-02 20:14:40 -04:00
Rapptz c8937ed2aa [commands] Add is_nsfw check. 2017-05-01 22:36:22 -04:00
Rapptz c9565e57d3 Make sure that the chunker task only runs once. 2017-05-01 22:34:24 -04:00
Rapptz ba2dad2093 Add support for setting and retrieving guild vanity invites. 2017-04-30 07:17:00 -04:00
Rapptz c54a6a927d Implement audit logs. 2017-04-30 02:58:27 -04:00
Rapptz 3f45db5c3b Better TextChannel.is_nsfw() check. 2017-04-30 02:53:33 -04:00
Rapptz 10453d6718 Add Client.get_emoji to get an Emoji from an ID. 2017-04-30 02:53:05 -04:00
Rapptz d3a86a5fb6 Add TextChannel.is_nsfw method to check for NSFW channels. 2017-04-26 21:02:30 -04:00
Rapptz 92d55077aa Don't set VoiceClient.channel to None when VOICE_STATE_UPDATE says so.
Sometimes VOICE_STATE_UPDATE gives us a channel_id: null payload and
we would end up clearing the VoiceClient.channel state along with
it.
2017-04-26 04:52:49 -04:00
Rapptz 37681dd0ea [commands] Fix lack of space in when_mentioned 2017-04-24 00:23:23 -04:00
Rapptz 6188397fc9 [commands] Add Context.voice_client shortcut. 2017-04-24 00:17:04 -04:00
Rapptz c005ef5d44 [commands] Make when_mentioned always have both mention formats.
This will allow it to work in mobile clients which don't respect the
<@!id> format in case of nicknames.
2017-04-24 00:13:27 -04:00
Rapptz e445fa9335 Wait 5 seconds before attempting to RESUME during INVALIDATE_SESSION. 2017-04-22 21:34:56 -04:00
Rapptz 1519a6fefa Fix some linting errors. 2017-04-22 04:50:31 -04:00
Rapptz c30ab8a3e5 Fix NameError in Role.edit when moving roles. 2017-04-22 04:47:43 -04:00
Rapptz 0ce781b37c Fix NameError in GuildChannel.changed_roles 2017-04-22 04:44:21 -04:00
Rapptz 3cfebc4605 Timeout when doing initial connection. 2017-04-22 02:18:35 -04:00
Rapptz b6ac856868 [commands] Allow loading cogs from folders.
Internally, instead of using module objects just use the `__module__`
attribute which is the same thing. From preliminary testing this seems
to work fine with both regular one-file-per-cog approaches and the
folder cog approach.

Fixes #126.
2017-04-21 18:57:28 -04:00
Rapptz b05d8790fc Allow using Reaction objects while adding or removing reactions. 2017-04-21 17:32:09 -04:00
Rapptz 83649d7f0a Support for new member message types. 2017-04-21 03:49:05 -04:00
Rapptz 34c60002bf Allow setting a default volume in PCMVolumeTransformer. 2017-04-19 17:33:16 -04:00
Rapptz f5cfc96aaf Add PCMVolumeTransformer to augment volume of a PCM stream.
This also introduces the idea of replacing the VoiceClient.source on
the fly. Note that this internally pauses and resumes the audio
stream.
2017-04-19 17:23:39 -04:00
Rapptz 07d5328873 Add VoiceClient.is_paused to query pause state. 2017-04-19 16:06:45 -04:00
Rapptz 55e63ed87f Add VoiceClient.source to get the AudioSource being played. 2017-04-19 01:19:39 -04:00
Rapptz efd6d11e9a Fix static cut-off when playing. 2017-04-18 22:20:40 -04:00
Rapptz aa32c384ea Clean cache when TimeoutError occurs. 2017-04-18 20:13:34 -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 b4bc4dfd12 Fix FFmpegPCMAudio not working with spaces in filename. 2017-04-18 16:05:32 -04:00
Rapptz 1fc08bc5a2 Remove unused imports. 2017-04-18 04:22:35 -04:00
Rapptz d534a0989e Properly cleanup of VoiceClients in cache. 2017-04-18 04:09:33 -04:00
Rapptz 65bd510df6 Add Guild.voice_client shortcut. 2017-04-18 04:07:05 -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 38fd0928df Don't clear state when READY is reached for auto sharded clients. 2017-04-16 02:32:23 -04:00
Rapptz 3983eb3ba5 Support for API v7 error handling. 2017-04-15 19:55:51 -04:00
Rapptz 22150b20b6 Start typing immediately when using async typing context manager. 2017-04-12 21:26:23 -04:00
Rapptz 0e5bf09021 Export missing enums. 2017-04-12 20:20:35 -04:00
Rapptz 728fae9285 Add Guild.explicit_content_filter. 2017-04-12 20:18:28 -04:00
Rapptz cadf6960b7 Use create_future wrapper for initially created Future. 2017-04-12 19:55:01 -04:00
Rapptz ac90159c72 Improve logging in more places.
This shows the Shard ID in more places, along with a gateway trace and
session ID. Also helps show the RESUME/IDENTIFY/RESUMED/READY flow a
bit more instead of it looking like the connection has zombied out.
2017-04-12 19:43:47 -04:00
Rapptz 3e15f46dcf [commands] Bot.get_all_emojis no longer exists. 2017-04-12 05:00:50 -04:00
Rapptz 7da0884bfb [commands] Export missing built-in converters. 2017-04-12 04:46:53 -04:00
Rapptz 982308da3c Use global user cache to fetch reaction event data.
Also make sure it isn't dispatched unless the data meets the integrity
checks (i.e. not None).
2017-04-09 21:37:49 -04:00
Rapptz 580b4baef9 Fix view_audit_log incorrect pluralisation. 2017-04-08 18:05:46 -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 e5c5695399 Proper recursion when launching shards. 2017-04-07 23:23:48 -04:00
Rapptz bcfb31779d Fix KeyError in certain logging cases. 2017-04-07 23:22:44 -04:00
Rapptz ff95258710 Use an asyncio.Event instead of an asyncio.Lock for global rate limits.
There were some dead-locking issues that I suspect were due to the
way the global rate limit was handled. This changes it into a simple
Event that allows multiple coroutines to pass through instead of one
by one.
2017-04-01 23:31:32 -04:00
Rapptz af0ba17885 Proper termination of HistoryIterator.flatten. 2017-03-30 03:27:44 -04:00
Rapptz 7f58853e3a Keep track of Emoji instances myself.
WeakValueDictionary cleans up too late and brings too little benefit.
Also clean up the state when the first READY is encountered for
AutoShardedClient and when any READY is encountered in regular Client.
2017-03-29 04:36:06 -04:00
Rapptz e1c32626ba [commands] Fix User converter not working with IDs. 2017-03-27 20:08:26 -04:00
Rapptz 5c5e7ae1d6 [commands] Add is_owner check and Bot.is_owner. 2017-03-27 06:55:21 -04:00
Rapptz afb64fb5e3 [commands] Remove Command.no_pm for commands.guild_only check.
This is a breaking change. The original purpose of no_pm has been
mainly a legacy aspect. They came from a time before checks were a
generalised concept and were never removed. A check is the proper way
to do its behaviour.
2017-03-26 21:41:34 -04:00
Rapptz cac84e517b Always overwrite Emoji references in the state.
There is potential that when recreating the Emoji list in the
GUILD_EMOJIS_UPDATE event would just fetch from cache and the element
in cache having an out of date Guild reference. This Guild reference
will be kept alive for longer than it should be.

By always overwriting the Emoji reference, this problem goes away.
2017-03-26 18:43:57 -04:00
Rapptz e749b19131 Remove unnecessary shielding.
This was causing the exception to be suppressed and print 'NoneType'
instead.
2017-03-25 03:30:49 -04:00
Rapptz fde35848f6 Make Role.members use a list comprehension. 2017-03-25 00:47:51 -04:00
Rapptz b88658f42f Allow Emoji to be used in a weakref. 2017-03-24 21:50:19 -04:00
Rapptz aef170d7e0 Fix memory leak by holding on to Emoji references weakly.
The library had a memory leak in the case using the global emoji cache.
When the bot would leave the guild, the Emoji would maintain a strong
reference to the Guild keeping them alive along with the entire state
associated with it.
2017-03-24 21:46:32 -04:00
Rapptz 46951e27f7 Revert "Reference the ConnectionState by weakref."
This reverts commit 730a0e2d53.
2017-03-24 21:44:33 -04:00
Rapptz 4160cd7d12 Set closed state before actually finishing cleaning up. 2017-03-24 20:40:23 -04:00
Rapptz 9885a946e1 More robust cleanup for Client.run.
This should prevent asyncio.CancelledError from being propagated more
and suppressed "Task was destroyed but was pending!" warnings when
doing graceful closes outside of using a KeyboardInterrupt.

To make clean up a bit more robust, also add signal handlers
for POSIX systems.
2017-03-24 20:27:30 -04:00
Rapptz 9fcbe5c678 Sort Guild.text_channels and Guild.voice_channels in UI order. 2017-03-23 19:34:36 -04:00
Rapptz 959c60543d Upgrade aiohttp requirement to 2.0.
Apparently this doesn't cause any issues with the existing code as-is.
I suspect the real issue will be with people's third party code.
2017-03-23 17:47:24 -04:00
Rapptz 730a0e2d53 Reference the ConnectionState by weakref instead of a strong reference.
Hopefully this means when the bot has some lingering object for
whatever reason, the memory doesn't double due to it having a strong
reference to an outdated connection state.
2017-03-22 00:02:50 -04:00
Rapptz 8a34c412ed Add Permissions.view_audit_log 2017-03-21 19:39:06 -04:00
Rapptz 31a7093433 [commands] Fix minor spacing issue in Command.signature 2017-03-21 15:36:52 -04:00
Rapptz fd62c8a4f1 Aggregate shard closing futures instead of doing them sequentially. 2017-03-21 03:52:24 -04:00
Rapptz 5461bfb475 Check if we're closed before attempting to do a reconnect. 2017-03-21 03:32:09 -04:00
Rapptz a0cdb19c5f Eventual consistency fixes. 2017-03-21 03:16:30 -04:00
Rapptz 3087600c8d [commands] Add Command.signature
This replaces HelpFormatter.get_command_signature for the most part.
2017-03-21 00:46:13 -04:00
Rapptz 54fdafb792 [commands] Add BotBase.get_cog_commands to get all a cog's commands.
Self-explanatory. This should help create help commands for a cog
more easily.
2017-03-21 00:46:12 -04:00
Rapptz fe588a4d52 [commands] Change GroupMixin.commands to all_commands
This is a breaking change as GroupMixin.commands now returns a set
of unique Command objects.
2017-03-21 00:46:12 -04:00
Rapptz c90e52450a Reconnect on any OSError. 2017-03-20 15:45:44 -04:00
Rapptz 4ffded622a Removing acking on channels. 2017-03-18 11:52:18 -04:00
Rapptz df0f1bfbdf Fix Client inability to shard by actually propagating the shard_id 2017-03-16 05:51:11 -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 51b0baeb9d Speed up message update handling.
Apparently, checking if something is not None and then calling it is
faster than having an identity function that will just return the
original value untransformed, such as a lambda or doing a str(str) call
2017-03-14 19:12:30 -04:00
Rapptz c089aa199b Remove Message.edited_timestamp in favour of Message.edited_at 2017-03-14 19:07:08 -04:00
Rapptz 1239e88d05 Handle aware datetimes in embeds. 2017-03-13 17:47:46 -04:00
Rapptz 9c6d9f1a84 Remove call handling for now. 2017-03-13 17:07:33 -04:00
Rapptz 058f1f13eb Fix premium key being missing in profile endpoint. 2017-03-13 00:26:43 -04:00
Rapptz d87d4e716f Retry on more exceptions in auto reconnect code. 2017-03-07 01:12:28 -05:00
Rapptz ead18e3948 Fix issue with members not copying correctly. 2017-03-05 07:48:15 -05:00
Rapptz 96a43fa9e3 Fix NameError in Role.edit 2017-03-05 06:48:18 -05:00
Rapptz 76e76f2905 Add underscore to HTTPClient.session to imply privateness. 2017-03-04 23:27:57 -05:00
Rapptz c4c17351c6 Add commit number to pip version for easy identification. 2017-03-04 20:43:05 -05:00
Rapptz aa41101237 Remove Client.accept_invite 2017-03-04 20:42:21 -05:00
Rapptz 98cfb53d3b [commands] Add Context.me property. 2017-03-01 18:58:56 -05:00
Rapptz 5ce88c8a3f Reconnect even if we close with 1000 since Discord can send it.
Rely on is_closed() instead since this is the true metric of a clean
closure.
2017-03-01 05:10:01 -05:00
Rapptz e78a5c0643 Remove remaining voice_member tracking. 2017-02-28 18:29:27 -05:00