492 Commits

Author SHA1 Message Date
Rapptz
50dcdac5ca [commands] Fix references in Bot to actually link.
Exceptions can't seem to link due to a bug in Sphinx.
2019-04-10 05:13:30 -04:00
Vexs
4df0f79a6b Add notes warning that fetch_ methods are api calls
Also recommends using cache attributes/methods instead
2019-04-10 00:55:45 -04:00
Rapptz
e77dec85e9 Fix cleanup code on Linux not working properly. 2019-04-09 00:56:36 -04:00
Rapptz
dcdcf1adac Stop the event loop if it's running during cleanup.
Also handle the coroutine directly instead of using run_until_complete
2019-04-09 00:14:42 -04:00
NCPlayz
7acb7de195 Add notes stating what Guild.fetch_guild and Guild.fetch_guilds returns
Also fixed two typos.
2019-04-08 18:17:40 -04:00
Rapptz
61ee88b0fc Fix oversight where on_disconnect did not get called on WS termination. 2019-04-08 07:45:05 -04:00
Rapptz
72b6152e96 Client.event raises TypeError instead of ClientException. 2019-04-07 22:33:38 -04:00
Rapptz
84c1eac62a Don't raise an exception during the signal handlers. 2019-04-07 16:10:44 -04:00
Rapptz
239d430539 Simplify bot loop cleanup routine.
Attempted solution for #2040
2019-04-06 21:29:57 -04:00
NCPlayz
be227ebcf0 Redesign asset retrieval in the library.
Most assets now return a new class named `Asset`. This allows for the
assets to be consistently saved via a `save` method instead of special
casing for `Attachment`.

`AppInfo` is no longer a namedtuple it is a fully documented dataclass,
as well as having the state attached to it.

Fixes #1997
2019-04-06 19:12:50 -04:00
NCPlayz
8a30a4cac0 Add support for guild widget 2019-03-19 09:22:48 -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
963cf4b34e Add on_disconnect event.
I assume this is where it has to be. Fix #1937
2019-03-18 05:29:38 -04:00
NCPlayz
8b8e9a619e Moved http.close to before _closed.set 2019-03-09 14:09:47 +00:00
Rapptz
5d78f43e55 Expose more information from partial invites, along with counts.
This adds the following information.

* `PartialInviteGuild` to replace `Object` patching
* `PartialInviteChannel` to replace `Object` patching
* Invite.approximate_member_count and Invite.approximate_presence_count

The new partial objects provide better documentation on what is
expected when you fetch random invites.

Fixes #1830
2019-02-12 20:22:47 -05:00
Dante Dam
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -05:00
Rapptz
1f2602d11e Support discordapp.com invite URLs. 2018-11-25 04:54:12 -05:00
SnowyLuma
e89e7dfe93 Add support for multiple activities 2018-11-24 22:36:52 -05:00
Hornwitser
1c3a5831f9 [lint] Removed unused variable handler
Left over by the removal of handlers in 2721689.
2018-11-24 22:17:58 -05:00
Hornwitser
df144b0959 [lint] Changed missed docstrings to raw-string
Missed by a4d1599 despite being pointed out in #1570.
2018-11-24 22:17:58 -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
fa46b07db1 [lint] Rename exception variables to exc
Use the more explicit (and common) exc instead of e as the variable
holding the exception in except handlers.
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
2721689254 Optimise tight loops in DiscordGateway.received_message
* type(x) is y is faster than isinstance(x, y)
* Re-arrange if-statements for common statements
* Drop handler getattr for most events that don't  use it
2018-09-24 23:22:49 -04:00
Rapptz
5c24e69cf2 Fix up the Sphinx strings causing warnings. 2018-09-15 09:54:00 -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
El Laggron
395af228b1 More informations for the Application info
This adds the rpc_origin, bot_public and
bot_require_code_grant attributes
2018-08-22 21:06:09 -04:00
Rapptz
8ccb98d395 Explicitly mark event handlers private 2018-08-09 03:27:39 -04:00
Rapptz
8d39ab8c8c Fix dumb typo in the warning. 2018-07-24 04:48:36 -04:00
Rapptz
12236325f6 Add a warning for self-bots in Client.login
Closes #1449
2018-07-24 03:48:51 -04:00
Kot
e15452e198 Add clarification about creating guilds 2018-07-24 03:45:28 -04:00
bmintz
87d9eefdef [docs] discord/client: remove reference to async_event 2018-07-19 21:27:30 -04:00
bmintz
ec3435b224 Remove remaining asyncio.coroutine calls.
Also remove Client.async_event
2018-07-05 03:45:58 -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
e9916e2844 Convert Client.activity back to an Activity-like object 2018-03-06 18:13:17 -05:00
Rapptz
61c8e35929 Missing import for _ActivityTag inside Client 2018-03-06 09:10:13 -05:00
Rapptz
0fcd385b9a Add ability to change the activity used when logging in at runtime. 2018-03-05 11:23:07 -05:00
Rapptz
f8f8f418f3 Split Game object to separate Activity subtypes for Rich Presences.
This is a massive breaking change.

* All references to "game" have been renamed to "activity"
* Activity objects contain a majority of the rich presence information
* Game and Streaming are subtypes for memory optimisation purposes for
  the more common cases.
* Introduce a more specialised read-only type, Spotify, for the
  official Spotify integration to make it easier to use.
2018-03-05 11:15:49 -05:00
Tobotimus
3112e1c17e Add intersphinx 2018-01-06 17:23:59 -05:00
Rapptz
e2f7945f59 Proper variable name in Client.clear. 2017-12-20 09:45:09 -05:00
Rapptz
5c5a59c18e Add Client.clear to clear the bot's internal state to a clean slate.
In case you want to have some external restart loop.
2017-12-16 21:36:39 -05:00
ReinaSakuraba
13632faf97 Fix AppInfo.id being a string 2017-10-02 13:38:05 -07:00
espeonofespeonage
fd531297d2 Changed discord.Client.event to debug log success instead of info log.
This is suggested to prevent spamming the console unnecesarilly.

Info should be used to output information to the user that is important, but
not a warning or an error. If I am bundling a bot as a modular package then
it doesn't really make sense to spam their console with every time a coroutine
is subscribed to, as it likely will not mean anything to the user. If they are
interested in this, it would make more sense to just to enable debugging first.

I have made this change, as I am writing a wrapper for this library for a
private project, and that will handle dispatching events, thus, I do not
need a prompt for each event that is subscribed to in this module outside of
DEBUG. Currently, with logging set to INFO, I am getting 47 lines reading:

    INFO:discord.client:coroutine has successfully been registered as an event

...being output as my bot starts, and without having to disable INFO logging
altogether, I am currently having to temporarily change the verbosity of the
logger as the events are initialised, which is not desirable as it could
potentially cover up any other INFO messages that would be useful to have
output.

Using a filter seems like a bit of a hacky workaround. If this isn't acceptable
then another alternative would be to add a parameter to the constructor of
discord.Client to enable or disable printing this information.
2017-09-23 12:50:12 +01:00
Rapptz
025136076a Add an example for on_reaction_add waiting.
Apparently people would rather read examples than the actual
documentation.
2017-09-18 05:46:51 -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
Rapptz
0f7482ed6e Add Client.latency, AutoShardedClient.latency and latencies.
This should allow an easier way to query the Discord protocol gateway
latency, defined by the difference HEARTBEAT_ACK between and the last
sent HEARTBEAT.
2017-08-15 23:41:11 -04:00