· 6 years ago · Jan 29, 2020, 09:16 PM
1.. currentmodule:: discord
2
3API Reference
4===============
5
6The following section outlines the API of discord.py.
7
8.. note::
9
10 This module uses the Python logging module to log diagnostic and errors
11 in an output independent way. If the logging module is not configured,
12 these logs will not be output anywhere. See :ref:`logging_setup` for
13 more information on how to set up and use the logging module with
14 discord.py.
15
16Version Related Info
17---------------------
18
19There are two main ways to query version information about the library. For guarantees, check :ref:`version_guarantees`.
20
21.. data:: version_info
22
23 A named tuple that is similar to :obj:`py:sys.version_info`.
24
25 Just like :obj:`py:sys.version_info` the valid values for ``releaselevel`` are
26 'alpha', 'beta', 'candidate' and 'final'.
27
28.. data:: __version__
29
30 A string representation of the version. e.g. ``'1.0.0rc1'``. This is based
31 off of :pep:`440`.
32
33Client
34-------
35
36.. autoclass:: Client
37 :members:
38
39.. autoclass:: AutoShardedClient
40 :members:
41
42.. autoclass:: AppInfo()
43 :members:
44
45.. autoclass:: Team()
46 :members:
47
48.. autoclass:: TeamMember()
49 :members:
50
51Voice
52------
53
54.. autoclass:: VoiceClient()
55 :members:
56
57.. autoclass:: AudioSource
58 :members:
59
60.. autoclass:: PCMAudio
61 :members:
62
63.. autoclass:: FFmpegAudio
64 :members:
65
66.. autoclass:: FFmpegPCMAudio
67 :members:
68
69.. autoclass:: FFmpegOpusAudio
70 :members:
71
72.. autoclass:: PCMVolumeTransformer
73 :members:
74
75Opus Library
76~~~~~~~~~~~~~
77
78.. autofunction:: discord.opus.load_opus
79
80.. autofunction:: discord.opus.is_loaded
81
82.. _discord-api-events:
83
84Event Reference
85---------------
86
87This page outlines the different types of events listened by :class:`Client`.
88
89There are two ways to register an event, the first way is through the use of
90:meth:`Client.event`. The second way is through subclassing :class:`Client` and
91overriding the specific events. For example: ::
92
93 import discord
94
95 class MyClient(discord.Client):
96 async def on_message(self, message):
97 if message.author == self.user:
98 return
99
100 if message.content.startswith('$hello'):
101 await message.channel.send('Hello World!')
102
103
104If an event handler raises an exception, :func:`on_error` will be called
105to handle it, which defaults to print a traceback and ignoring the exception.
106
107.. warning::
108
109 All the events must be a |coroutine_link|_. If they aren't, then you might get unexpected
110 errors. In order to turn a function into a coroutine they must be ``async def``
111 functions.
112
113.. function:: on_connect()
114
115 Called when the client has successfully connected to Discord. This is not
116 the same as the client being fully prepared, see :func:`on_ready` for that.
117
118 The warnings on :func:`on_ready` also apply.
119
120.. function:: on_disconnect()
121
122 Called when the client has disconnected from Discord. This could happen either through
123 the internet being disconnected, explicit calls to logout, or Discord terminating the connection
124 one way or the other.
125
126 This function can be called many times.
127
128.. function:: on_ready()
129
130 Called when the client is done preparing the data received from Discord. Usually after login is successful
131 and the :attr:`Client.guilds` and co. are filled up.
132
133 .. warning::
134
135 This function is not guaranteed to be the first event called.
136 Likewise, this function is **not** guaranteed to only be called
137 once. This library implements reconnection logic and thus will
138 end up calling this event whenever a RESUME request fails.
139
140.. function:: on_shard_ready(shard_id)
141
142 Similar to :func:`on_ready` except used by :class:`AutoShardedClient`
143 to denote when a particular shard ID has become ready.
144
145 :param shard_id: The shard ID that is ready.
146 :type shard_id: :class:`int`
147
148.. function:: on_resumed()
149
150 Called when the client has resumed a session.
151
152.. function:: on_error(event, \*args, \*\*kwargs)
153
154 Usually when an event raises an uncaught exception, a traceback is
155 printed to stderr and the exception is ignored. If you want to
156 change this behaviour and handle the exception for whatever reason
157 yourself, this event can be overridden. Which, when done, will
158 suppress the default action of printing the traceback.
159
160 The information of the exception raised and the exception itself can
161 be retrieved with a standard call to :func:`sys.exc_info`.
162
163 If you want exception to propagate out of the :class:`Client` class
164 you can define an ``on_error`` handler consisting of a single empty
165 :ref:`py:raise`. Exceptions raised by ``on_error`` will not be
166 handled in any way by :class:`Client`.
167
168 :param event: The name of the event that raised the exception.
169 :type event: :class:`str`
170
171 :param args: The positional arguments for the event that raised the
172 exception.
173 :param kwargs: The keyword arguments for the event that raised the
174 exception.
175
176.. function:: on_socket_raw_receive(msg)
177
178 Called whenever a message is received from the WebSocket, before
179 it's processed. This event is always dispatched when a message is
180 received and the passed data is not processed in any way.
181
182 This is only really useful for grabbing the WebSocket stream and
183 debugging purposes.
184
185 .. note::
186
187 This is only for the messages received from the client
188 WebSocket. The voice WebSocket will not trigger this event.
189
190 :param msg: The message passed in from the WebSocket library.
191 Could be :class:`bytes` for a binary message or :class:`str`
192 for a regular message.
193 :type msg: Union[:class:`bytes`, :class:`str`]
194
195.. function:: on_socket_raw_send(payload)
196
197 Called whenever a send operation is done on the WebSocket before the
198 message is sent. The passed parameter is the message that is being
199 sent to the WebSocket.
200
201 This is only really useful for grabbing the WebSocket stream and
202 debugging purposes.
203
204 .. note::
205
206 This is only for the messages received from the client
207 WebSocket. The voice WebSocket will not trigger this event.
208
209 :param payload: The message that is about to be passed on to the
210 WebSocket library. It can be :class:`bytes` to denote a binary
211 message or :class:`str` to denote a regular text message.
212
213.. function:: on_typing(channel, user, when)
214
215 Called when someone begins typing a message.
216
217 The ``channel`` parameter can be a :class:`abc.Messageable` instance.
218 Which could either be :class:`TextChannel`, :class:`GroupChannel`, or
219 :class:`DMChannel`.
220
221 If the ``channel`` is a :class:`TextChannel` then the ``user`` parameter
222 is a :class:`Member`, otherwise it is a :class:`User`.
223
224 :param channel: The location where the typing originated from.
225 :type channel: :class:`abc.Messageable`
226 :param user: The user that started typing.
227 :type user: Union[:class:`User`, :class:`Member`]
228 :param when: When the typing started as a naive datetime in UTC.
229 :type when: :class:`datetime.datetime`
230
231.. function:: on_message(message)
232
233 Called when a :class:`Message` is created and sent.
234
235 .. warning::
236
237 Your bot's own messages and private messages are sent through this
238 event. This can lead cases of 'recursion' depending on how your bot was
239 programmed. If you want the bot to not reply to itself, consider
240 checking the user IDs. Note that :class:`~ext.commands.Bot` does not
241 have this problem.
242
243 :param message: The current message.
244 :type message: :class:`Message`
245
246.. function:: on_message_delete(message)
247
248 Called when a message is deleted. If the message is not found in the
249 internal message cache, then this event will not be called.
250 Messages might not be in cache if the message is too old
251 or the client is participating in high traffic guilds.
252
253 If this occurs increase the :attr:`Client.max_messages` attribute
254 or use the :func:`on_raw_message_delete` event instead.
255
256 :param message: The deleted message.
257 :type message: :class:`Message`
258
259.. function:: on_bulk_message_delete(messages)
260
261 Called when messages are bulk deleted. If none of the messages deleted
262 are found in the internal message cache, then this event will not be called.
263 If individual messages were not found in the internal message cache,
264 this event will still be called, but the messages not found will not be included in
265 the messages list. Messages might not be in cache if the message is too old
266 or the client is participating in high traffic guilds.
267
268 If this occurs increase the :attr:`Client.max_messages` attribute
269 or use the :func:`on_raw_bulk_message_delete` event instead.
270
271 :param messages: The messages that have been deleted.
272 :type messages: List[:class:`Message`]
273
274.. function:: on_raw_message_delete(payload)
275
276 Called when a message is deleted. Unlike :func:`on_message_delete`, this is
277 called regardless of the message being in the internal message cache or not.
278
279 If the message is found in the message cache,
280 it can be accessed via :attr:`RawMessageDeleteEvent.cached_message`
281
282 :param payload: The raw event payload data.
283 :type payload: :class:`RawMessageDeleteEvent`
284
285.. function:: on_raw_bulk_message_delete(payload)
286
287 Called when a bulk delete is triggered. Unlike :func:`on_bulk_message_delete`, this is
288 called regardless of the messages being in the internal message cache or not.
289
290 If the messages are found in the message cache,
291 they can be accessed via :attr:`RawBulkMessageDeleteEvent.cached_messages`
292
293 :param payload: The raw event payload data.
294 :type payload: :class:`RawBulkMessageDeleteEvent`
295
296.. function:: on_message_edit(before, after)
297
298 Called when a :class:`Message` receives an update event. If the message is not found
299 in the internal message cache, then these events will not be called.
300 Messages might not be in cache if the message is too old
301 or the client is participating in high traffic guilds.
302
303 If this occurs increase the :attr:`Client.max_messages` attribute
304 or use the :func:`on_raw_message_edit` event instead.
305
306 The following non-exhaustive cases trigger this event:
307
308 - A message has been pinned or unpinned.
309 - The message content has been changed.
310 - The message has received an embed.
311
312 - For performance reasons, the embed server does not do this in a "consistent" manner.
313
314 - The message's embeds were suppressed or unsuppressed.
315 - A call message has received an update to its participants or ending time.
316
317 :param before: The previous version of the message.
318 :type before: :class:`Message`
319 :param after: The current version of the message.
320 :type after: :class:`Message`
321
322.. function:: on_raw_message_edit(payload)
323
324 Called when a message is edited. Unlike :func:`on_message_edit`, this is called
325 regardless of the state of the internal message cache.
326
327 If the message is found in the message cache,
328 it can be accessed via :attr:`RawMessageUpdateEvent.cached_message`
329
330 Due to the inherently raw nature of this event, the data parameter coincides with
331 the raw data given by the `gateway <https://discordapp.com/developers/docs/topics/gateway#message-update>`_.
332
333 Since the data payload can be partial, care must be taken when accessing stuff in the dictionary.
334 One example of a common case of partial data is when the ``'content'`` key is inaccessible. This
335 denotes an "embed" only edit, which is an edit in which only the embeds are updated by the Discord
336 embed server.
337
338 :param payload: The raw event payload data.
339 :type payload: :class:`RawMessageUpdateEvent`
340
341.. function:: on_reaction_add(reaction, user)
342
343 Called when a message has a reaction added to it. Similar to :func:`on_message_edit`,
344 if the message is not found in the internal message cache, then this
345 event will not be called. Consider using :func:`on_raw_reaction_add` instead.
346
347 .. note::
348
349 To get the :class:`Message` being reacted, access it via :attr:`Reaction.message`.
350
351 :param reaction: The current state of the reaction.
352 :type reaction: :class:`Reaction`
353 :param user: The user who added the reaction.
354 :type user: Union[:class:`Member`, :class:`User`]
355
356.. function:: on_raw_reaction_add(payload)
357
358 Called when a message has a reaction added. Unlike :func:`on_reaction_add`, this is
359 called regardless of the state of the internal message cache.
360
361 :param payload: The raw event payload data.
362 :type payload: :class:`RawReactionActionEvent`
363
364.. function:: on_reaction_remove(reaction, user)
365
366 Called when a message has a reaction removed from it. Similar to on_message_edit,
367 if the message is not found in the internal message cache, then this event
368 will not be called.
369
370 .. note::
371
372 To get the message being reacted, access it via :attr:`Reaction.message`.
373
374 :param reaction: The current state of the reaction.
375 :type reaction: :class:`Reaction`
376 :param user: The user who added the reaction.
377 :type user: Union[:class:`Member`, :class:`User`]
378
379.. function:: on_raw_reaction_remove(payload)
380
381 Called when a message has a reaction removed. Unlike :func:`on_reaction_remove`, this is
382 called regardless of the state of the internal message cache.
383
384 :param payload: The raw event payload data.
385 :type payload: :class:`RawReactionActionEvent`
386
387.. function:: on_reaction_clear(message, reactions)
388
389 Called when a message has all its reactions removed from it. Similar to :func:`on_message_edit`,
390 if the message is not found in the internal message cache, then this event
391 will not be called. Consider using :func:`on_raw_reaction_clear` instead.
392
393 :param message: The message that had its reactions cleared.
394 :type message: :class:`Message`
395 :param reactions: The reactions that were removed.
396 :type reactions: List[:class:`Reaction`]
397
398.. function:: on_raw_reaction_clear(payload)
399
400 Called when a message has all its reactions removed. Unlike :func:`on_reaction_clear`,
401 this is called regardless of the state of the internal message cache.
402
403 :param payload: The raw event payload data.
404 :type payload: :class:`RawReactionClearEvent`
405
406.. function:: on_reaction_clear_emoji(reaction)
407
408 Called when a message has a specific reaction removed from it. Similar to :func:`on_message_edit`,
409 if the message is not found in the internal message cache, then this event
410 will not be called. Consider using :func:`on_raw_reaction_clear_emoji` instead.
411
412 .. versionadded:: 1.3
413
414 :param reaction: The reaction that got cleared.
415 :type reaction: :class:`Reaction`
416
417.. function:: on_raw_reaction_clear_emoji(payload)
418
419 Called when a message has a specific reaction removed from it. Unlike :func:`on_reaction_clear_emoji` this is called
420 regardless of the state of the internal message cache.
421
422 .. versionadded:: 1.3
423
424 :param payload: The raw event payload data.
425 :type payload: :class:`RawReactionClearEmojiEvent`
426
427.. function:: on_private_channel_delete(channel)
428 on_private_channel_create(channel)
429
430 Called whenever a private channel is deleted or created.
431
432 :param channel: The private channel that got created or deleted.
433 :type channel: :class:`abc.PrivateChannel`
434
435.. function:: on_private_channel_update(before, after)
436
437 Called whenever a private group DM is updated. e.g. changed name or topic.
438
439 :param before: The updated group channel's old info.
440 :type before: :class:`GroupChannel`
441 :param after: The updated group channel's new info.
442 :type after: :class:`GroupChannel`
443
444.. function:: on_private_channel_pins_update(channel, last_pin)
445
446 Called whenever a message is pinned or unpinned from a private channel.
447
448 :param channel: The private channel that had its pins updated.
449 :type channel: :class:`abc.PrivateChannel`
450 :param last_pin: The latest message that was pinned as a naive datetime in UTC. Could be ``None``.
451 :type last_pin: Optional[:class:`datetime.datetime`]
452
453.. function:: on_guild_channel_delete(channel)
454 on_guild_channel_create(channel)
455
456 Called whenever a guild channel is deleted or created.
457
458 Note that you can get the guild from :attr:`~abc.GuildChannel.guild`.
459
460 :param channel: The guild channel that got created or deleted.
461 :type channel: :class:`abc.GuildChannel`
462
463.. function:: on_guild_channel_update(before, after)
464
465 Called whenever a guild channel is updated. e.g. changed name, topic, permissions.
466
467 :param before: The updated guild channel's old info.
468 :type before: :class:`abc.GuildChannel`
469 :param after: The updated guild channel's new info.
470 :type after: :class:`abc.GuildChannel`
471
472.. function:: on_guild_channel_pins_update(channel, last_pin)
473
474 Called whenever a message is pinned or unpinned from a guild channel.
475
476 :param channel: The guild channel that had its pins updated.
477 :type channel: :class:`abc.GuildChannel`
478 :param last_pin: The latest message that was pinned as a naive datetime in UTC. Could be ``None``.
479 :type last_pin: Optional[:class:`datetime.datetime`]
480
481.. function:: on_guild_integrations_update(guild)
482
483 Called whenever an integration is created, modified, or removed from a guild.
484
485 :param guild: The guild that had its integrations updated.
486 :type guild: :class:`Guild`
487
488.. function:: on_webhooks_update(channel)
489
490 Called whenever a webhook is created, modified, or removed from a guild channel.
491
492 :param channel: The channel that had its webhooks updated.
493 :type channel: :class:`abc.GuildChannel`
494
495.. function:: on_member_join(member)
496 on_member_remove(member)
497
498 Called when a :class:`Member` leaves or joins a :class:`Guild`.
499
500 :param member: The member who joined or left.
501 :type member: :class:`Member`
502
503.. function:: on_member_update(before, after)
504
505 Called when a :class:`Member` updates their profile.
506
507 This is called when one or more of the following things change:
508
509 - status
510 - activity
511 - nickname
512 - roles
513
514 :param before: The updated member's old info.
515 :type before: :class:`Member`
516 :param after: The updated member's updated info.
517 :type after: :class:`Member`
518
519.. function:: on_user_update(before, after)
520
521 Called when a :class:`User` updates their profile.
522
523 This is called when one or more of the following things change:
524
525 - avatar
526 - username
527 - discriminator
528
529 :param before: The updated user's old info.
530 :type before: :class:`User`
531 :param after: The updated user's updated info.
532 :type after: :class:`User`
533
534.. function:: on_guild_join(guild)
535
536 Called when a :class:`Guild` is either created by the :class:`Client` or when the
537 :class:`Client` joins a guild.
538
539 :param guild: The guild that was joined.
540 :type guild: :class:`Guild`
541
542.. function:: on_guild_remove(guild)
543
544 Called when a :class:`Guild` is removed from the :class:`Client`.
545
546 This happens through, but not limited to, these circumstances:
547
548 - The client got banned.
549 - The client got kicked.
550 - The client left the guild.
551 - The client or the guild owner deleted the guild.
552
553 In order for this event to be invoked then the :class:`Client` must have
554 been part of the guild to begin with. (i.e. it is part of :attr:`Client.guilds`)
555
556 :param guild: The guild that got removed.
557 :type guild: :class:`Guild`
558
559.. function:: on_guild_update(before, after)
560
561 Called when a :class:`Guild` updates, for example:
562
563 - Changed name
564 - Changed AFK channel
565 - Changed AFK timeout
566 - etc
567
568 :param before: The guild prior to being updated.
569 :type before: :class:`Guild`
570 :param after: The guild after being updated.
571 :type after: :class:`Guild`
572
573.. function:: on_guild_role_create(role)
574 on_guild_role_delete(role)
575
576 Called when a :class:`Guild` creates or deletes a new :class:`Role`.
577
578 To get the guild it belongs to, use :attr:`Role.guild`.
579
580 :param role: The role that was created or deleted.
581 :type role: :class:`Role`
582
583.. function:: on_guild_role_update(before, after)
584
585 Called when a :class:`Role` is changed guild-wide.
586
587 :param before: The updated role's old info.
588 :type before: :class:`Role`
589 :param after: The updated role's updated info.
590 :type after: :class:`Role`
591
592.. function:: on_guild_emojis_update(guild, before, after)
593
594 Called when a :class:`Guild` adds or removes :class:`Emoji`.
595
596 :param guild: The guild who got their emojis updated.
597 :type guild: :class:`Guild`
598 :param before: A list of emojis before the update.
599 :type before: Sequence[:class:`Emoji`]
600 :param after: A list of emojis after the update.
601 :type after: Sequence[:class:`Emoji`]
602
603.. function:: on_guild_available(guild)
604 on_guild_unavailable(guild)
605
606 Called when a guild becomes available or unavailable. The guild must have
607 existed in the :attr:`Client.guilds` cache.
608
609 :param guild: The :class:`Guild` that has changed availability.
610
611.. function:: on_voice_state_update(member, before, after)
612
613 Called when a :class:`Member` changes their :class:`VoiceState`.
614
615 The following, but not limited to, examples illustrate when this event is called:
616
617 - A member joins a voice channel.
618 - A member leaves a voice channel.
619 - A member is muted or deafened by their own accord.
620 - A member is muted or deafened by a guild administrator.
621
622 :param member: The member whose voice states changed.
623 :type member: :class:`Member`
624 :param before: The voice state prior to the changes.
625 :type before: :class:`VoiceState`
626 :param after: The voice state after to the changes.
627 :type after: :class:`VoiceState`
628
629.. function:: on_member_ban(guild, user)
630
631 Called when user gets banned from a :class:`Guild`.
632
633 :param guild: The guild the user got banned from.
634 :type guild: :class:`Guild`
635 :param user: The user that got banned.
636 Can be either :class:`User` or :class:`Member` depending if
637 the user was in the guild or not at the time of removal.
638 :type user: Union[:class:`User`, :class:`Member`]
639
640.. function:: on_member_unban(guild, user)
641
642 Called when a :class:`User` gets unbanned from a :class:`Guild`.
643
644 :param guild: The guild the user got unbanned from.
645 :type guild: :class:`Guild`
646 :param user: The user that got unbanned.
647 :type user: :class:`User`
648
649.. function:: on_invite_create(invite)
650
651 Called when an :class:`Invite` is created.
652
653 .. versionadded:: 1.3
654
655 .. note::
656
657 There is a rare possibility that the :attr:`Invite.guild` and :attr:`Invite.channel`
658 attributes will be of :class:`Object` rather than the respective models.
659
660 :param invite: The invite that was created.
661 :type invite: :class:`Invite`
662
663.. function:: on_invite_delete(invite)
664
665 Called when an :class:`Invite` is deleted.
666
667 .. versionadded:: 1.3
668
669 .. note::
670
671 There is a rare possibility that the :attr:`Invite.guild` and :attr:`Invite.channel`
672 attributes will be of :class:`Object` rather than the respective models.
673
674 Outside of those two attributes, the only other attribute guaranteed to be
675 filled by the Discord gateway for this event is :attr:`Invite.code`.
676
677 :param invite: The invite that was deleted.
678 :type invite: :class:`Invite`
679
680.. function:: on_group_join(channel, user)
681 on_group_remove(channel, user)
682
683 Called when someone joins or leaves a :class:`GroupChannel`.
684
685 :param channel: The group that the user joined or left.
686 :type channel: :class:`GroupChannel`
687 :param user: The user that joined or left.
688 :type user: :class:`User`
689
690.. function:: on_relationship_add(relationship)
691 on_relationship_remove(relationship)
692
693 Called when a :class:`Relationship` is added or removed from the
694 :class:`ClientUser`.
695
696 :param relationship: The relationship that was added or removed.
697 :type relationship: :class:`Relationship`
698
699.. function:: on_relationship_update(before, after)
700
701 Called when a :class:`Relationship` is updated, e.g. when you
702 block a friend or a friendship is accepted.
703
704 :param before: The previous relationship status.
705 :type before: :class:`Relationship`
706 :param after: The updated relationship status.
707 :type after: :class:`Relationship`
708
709.. _discord-api-utils:
710
711Utility Functions
712-----------------
713
714.. autofunction:: discord.utils.find
715
716.. autofunction:: discord.utils.get
717
718.. autofunction:: discord.utils.snowflake_time
719
720.. autofunction:: discord.utils.oauth_url
721
722.. autofunction:: discord.utils.escape_markdown
723
724.. autofunction:: discord.utils.escape_mentions
725
726.. autofunction:: discord.utils.resolve_invite
727
728.. autofunction:: discord.utils.sleep_until
729
730Profile
731---------
732
733.. class:: Profile
734
735 A namedtuple representing a user's Discord public profile.
736
737 .. attribute:: user
738
739 The :class:`User` the profile belongs to.
740 .. attribute:: premium
741
742 A boolean indicating if the user has premium (i.e. Discord Nitro).
743 .. attribute:: nitro
744
745 An alias for :attr:`premium`.
746 .. attribute:: premium_since
747
748 A naive UTC datetime indicating how long the user has been premium since.
749 This could be ``None`` if not applicable.
750 .. attribute:: staff
751
752 A boolean indicating if the user is Discord Staff.
753 .. attribute:: partner
754
755 A boolean indicating if the user is a Discord Partner.
756 .. attribute:: bug_hunter
757
758 A boolean indicating if the user is a Bug Hunter.
759 .. attribute:: early_supporter
760
761 A boolean indicating if the user has had premium before 10 October, 2018.
762 .. attribute:: hypesquad
763
764 A boolean indicating if the user is in Discord HypeSquad.
765 .. attribute:: hypesquad_houses
766
767 A list of :class:`HypeSquadHouse` that the user is in.
768 .. attribute:: team_user
769
770 A boolean indicating if the user is in part of a team.
771
772 .. versionadded:: 1.3
773
774 .. attribute:: system
775
776 A boolean indicating if the user is officially part of the Discord urgent message system.
777
778 .. versionadded:: 1.3
779
780 .. attribute:: mutual_guilds
781
782 A list of :class:`Guild` that the :class:`ClientUser` shares with this
783 user.
784 .. attribute:: connected_accounts
785
786 A list of dict objects indicating the accounts the user has connected.
787
788 An example entry can be seen below: ::
789
790 {type: "twitch", id: "92473777", name: "discordapp"}
791
792.. _discord-api-enums:
793
794Enumerations
795-------------
796
797The API provides some enumerations for certain types of strings to avoid the API
798from being stringly typed in case the strings change in the future.
799
800All enumerations are subclasses of an internal class which mimics the behaviour
801of :class:`enum.Enum`.
802
803.. class:: ChannelType
804
805 Specifies the type of channel.
806
807 .. attribute:: text
808
809 A text channel.
810 .. attribute:: voice
811
812 A voice channel.
813 .. attribute:: private
814
815 A private text channel. Also called a direct message.
816 .. attribute:: group
817
818 A private group text channel.
819 .. attribute:: news
820
821 A guild news channel.
822
823 .. attribute:: store
824
825 A guild store channel.
826
827.. class:: MessageType
828
829 Specifies the type of :class:`Message`. This is used to denote if a message
830 is to be interpreted as a system message or a regular message.
831
832 .. attribute:: default
833
834 The default message type. This is the same as regular messages.
835 .. attribute:: recipient_add
836
837 The system message when a recipient is added to a group private
838 message, i.e. a private channel of type :attr:`ChannelType.group`.
839 .. attribute:: recipient_remove
840
841 The system message when a recipient is removed from a group private
842 message, i.e. a private channel of type :attr:`ChannelType.group`.
843 .. attribute:: call
844
845 The system message denoting call state, e.g. missed call, started call,
846 etc.
847 .. attribute:: channel_name_change
848
849 The system message denoting that a channel's name has been changed.
850 .. attribute:: channel_icon_change
851
852 The system message denoting that a channel's icon has been changed.
853 .. attribute:: pins_add
854
855 The system message denoting that a pinned message has been added to a channel.
856 .. attribute:: new_member
857
858 The system message denoting that a new member has joined a Guild.
859
860 .. attribute:: premium_guild_subscription
861
862 The system message denoting that a member has "nitro boosted" a guild.
863 .. attribute:: premium_guild_tier_1
864
865 The system message denoting that a member has "nitro boosted" a guild
866 and it achieved level 1.
867 .. attribute:: premium_guild_tier_2
868
869 The system message denoting that a member has "nitro boosted" a guild
870 and it achieved level 2.
871 .. attribute:: premium_guild_tier_3
872
873 The system message denoting that a member has "nitro boosted" a guild
874 and it achieved level 3.
875 .. attribute:: channel_follow_add
876
877 The system message denoting that an announcement channel has been followed.
878
879 .. versionadded:: 1.3
880
881.. class:: ActivityType
882
883 Specifies the type of :class:`Activity`. This is used to check how to
884 interpret the activity itself.
885
886 .. attribute:: unknown
887
888 An unknown activity type. This should generally not happen.
889 .. attribute:: playing
890
891 A "Playing" activity type.
892 .. attribute:: streaming
893
894 A "Streaming" activity type.
895 .. attribute:: listening
896
897 A "Listening" activity type.
898 .. attribute:: watching
899
900 A "Watching" activity type.
901 .. attribute:: custom
902
903 A custom activity type.
904
905.. class:: HypeSquadHouse
906
907 Specifies the HypeSquad house a user belongs to.
908
909 .. attribute:: bravery
910
911 The "Bravery" house.
912 .. attribute:: brilliance
913
914 The "Brilliance" house.
915 .. attribute:: balance
916
917 The "Balance" house.
918
919.. class:: VoiceRegion
920
921 Specifies the region a voice server belongs to.
922
923 .. attribute:: amsterdam
924
925 The Amsterdam region.
926 .. attribute:: brazil
927
928 The Brazil region.
929 .. attribute:: dubai
930
931 The Dubai region.
932
933 .. versionadded:: 1.3
934
935 .. attribute:: eu_central
936
937 The EU Central region.
938 .. attribute:: eu_west
939
940 The EU West region.
941 .. attribute:: europe
942
943 The Europe region.
944
945 .. versionadded:: 1.3
946
947 .. attribute:: frankfurt
948
949 The Frankfurt region.
950 .. attribute:: hongkong
951
952 The Hong Kong region.
953 .. attribute:: india
954
955 The India region.
956
957 .. versionadded:: 1.2
958
959 .. attribute:: japan
960
961 The Japan region.
962 .. attribute:: london
963
964 The London region.
965 .. attribute:: russia
966
967 The Russia region.
968 .. attribute:: singapore
969
970 The Singapore region.
971 .. attribute:: southafrica
972
973 The South Africa region.
974 .. attribute:: sydney
975
976 The Sydney region.
977 .. attribute:: us_central
978
979 The US Central region.
980 .. attribute:: us_east
981
982 The US East region.
983 .. attribute:: us_south
984
985 The US South region.
986 .. attribute:: us_west
987
988 The US West region.
989 .. attribute:: vip_amsterdam
990
991 The Amsterdam region for VIP guilds.
992 .. attribute:: vip_us_east
993
994 The US East region for VIP guilds.
995 .. attribute:: vip_us_west
996
997 The US West region for VIP guilds.
998
999.. class:: VerificationLevel
1000
1001 Specifies a :class:`Guild`\'s verification level, which is the criteria in
1002 which a member must meet before being able to send messages to the guild.
1003
1004 .. container:: operations
1005
1006 .. describe:: x == y
1007
1008 Checks if two verification levels are equal.
1009 .. describe:: x != y
1010
1011 Checks if two verification levels are not equal.
1012 .. describe:: x > y
1013
1014 Checks if a verification level is higher than another.
1015 .. describe:: x < y
1016
1017 Checks if a verification level is lower than another.
1018 .. describe:: x >= y
1019
1020 Checks if a verification level is higher or equal to another.
1021 .. describe:: x <= y
1022
1023 Checks if a verification level is lower or equal to another.
1024
1025 .. attribute:: none
1026
1027 No criteria set.
1028 .. attribute:: low
1029
1030 Member must have a verified email on their Discord account.
1031 .. attribute:: medium
1032
1033 Member must have a verified email and be registered on Discord for more
1034 than five minutes.
1035 .. attribute:: high
1036
1037 Member must have a verified email, be registered on Discord for more
1038 than five minutes, and be a member of the guild itself for more than
1039 ten minutes.
1040 .. attribute:: table_flip
1041
1042 An alias for :attr:`high`.
1043 .. attribute:: extreme
1044
1045 Member must have a verified phone on their Discord account.
1046
1047 .. attribute:: double_table_flip
1048
1049 An alias for :attr:`extreme`.
1050
1051.. class:: NotificationLevel
1052
1053 Specifies whether a :class:`Guild` has notifications on for all messages or mentions only by default.
1054
1055 .. attribute:: all_messages
1056
1057 Members receive notifications for every message regardless of them being mentioned.
1058 .. attribute:: only_mentions
1059
1060 Members receive notifications for messages they are mentioned in.
1061
1062.. class:: ContentFilter
1063
1064 Specifies a :class:`Guild`\'s explicit content filter, which is the machine
1065 learning algorithms that Discord uses to detect if an image contains
1066 pornography or otherwise explicit content.
1067
1068 .. container:: operations
1069
1070 .. describe:: x == y
1071
1072 Checks if two content filter levels are equal.
1073 .. describe:: x != y
1074
1075 Checks if two content filter levels are not equal.
1076 .. describe:: x > y
1077
1078 Checks if a content filter level is higher than another.
1079 .. describe:: x < y
1080
1081 Checks if a content filter level is lower than another.
1082 .. describe:: x >= y
1083
1084 Checks if a content filter level is higher or equal to another.
1085 .. describe:: x <= y
1086
1087 Checks if a content filter level is lower or equal to another.
1088
1089 .. attribute:: disabled
1090
1091 The guild does not have the content filter enabled.
1092 .. attribute:: no_role
1093
1094 The guild has the content filter enabled for members without a role.
1095 .. attribute:: all_members
1096
1097 The guild has the content filter enabled for every member.
1098
1099.. class:: Status
1100
1101 Specifies a :class:`Member` 's status.
1102
1103 .. attribute:: online
1104
1105 The member is online.
1106 .. attribute:: offline
1107
1108 The member is offline.
1109 .. attribute:: idle
1110
1111 The member is idle.
1112 .. attribute:: dnd
1113
1114 The member is "Do Not Disturb".
1115 .. attribute:: do_not_disturb
1116
1117 An alias for :attr:`dnd`.
1118 .. attribute:: invisible
1119
1120 The member is "invisible". In reality, this is only used in sending
1121 a presence a la :meth:`Client.change_presence`. When you receive a
1122 user's presence this will be :attr:`offline` instead.
1123
1124
1125.. class:: AuditLogAction
1126
1127 Represents the type of action being done for a :class:`AuditLogEntry`\,
1128 which is retrievable via :meth:`Guild.audit_logs`.
1129
1130 .. attribute:: guild_update
1131
1132 The guild has updated. Things that trigger this include:
1133
1134 - Changing the guild vanity URL
1135 - Changing the guild invite splash
1136 - Changing the guild AFK channel or timeout
1137 - Changing the guild voice server region
1138 - Changing the guild icon
1139 - Changing the guild moderation settings
1140 - Changing things related to the guild widget
1141
1142 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1143 the :class:`Guild`.
1144
1145 Possible attributes for :class:`AuditLogDiff`:
1146
1147 - :attr:`~AuditLogDiff.afk_channel`
1148 - :attr:`~AuditLogDiff.system_channel`
1149 - :attr:`~AuditLogDiff.afk_timeout`
1150 - :attr:`~AuditLogDiff.default_message_notifications`
1151 - :attr:`~AuditLogDiff.explicit_content_filter`
1152 - :attr:`~AuditLogDiff.mfa_level`
1153 - :attr:`~AuditLogDiff.name`
1154 - :attr:`~AuditLogDiff.owner`
1155 - :attr:`~AuditLogDiff.splash`
1156 - :attr:`~AuditLogDiff.vanity_url_code`
1157
1158 .. attribute:: channel_create
1159
1160 A new channel was created.
1161
1162 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1163 either a :class:`abc.GuildChannel` or :class:`Object` with an ID.
1164
1165 A more filled out object in the :class:`Object` case can be found
1166 by using :attr:`~AuditLogEntry.after`.
1167
1168 Possible attributes for :class:`AuditLogDiff`:
1169
1170 - :attr:`~AuditLogDiff.name`
1171 - :attr:`~AuditLogDiff.type`
1172 - :attr:`~AuditLogDiff.overwrites`
1173
1174 .. attribute:: channel_update
1175
1176 A channel was updated. Things that trigger this include:
1177
1178 - The channel name or topic was changed
1179 - The channel bitrate was changed
1180
1181 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1182 the :class:`abc.GuildChannel` or :class:`Object` with an ID.
1183
1184 A more filled out object in the :class:`Object` case can be found
1185 by using :attr:`~AuditLogEntry.after` or :attr:`~AuditLogEntry.before`.
1186
1187 Possible attributes for :class:`AuditLogDiff`:
1188
1189 - :attr:`~AuditLogDiff.name`
1190 - :attr:`~AuditLogDiff.type`
1191 - :attr:`~AuditLogDiff.position`
1192 - :attr:`~AuditLogDiff.overwrites`
1193 - :attr:`~AuditLogDiff.topic`
1194 - :attr:`~AuditLogDiff.bitrate`
1195
1196 .. attribute:: channel_delete
1197
1198 A channel was deleted.
1199
1200 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1201 an :class:`Object` with an ID.
1202
1203 A more filled out object can be found by using the
1204 :attr:`~AuditLogEntry.before` object.
1205
1206 Possible attributes for :class:`AuditLogDiff`:
1207
1208 - :attr:`~AuditLogDiff.name`
1209 - :attr:`~AuditLogDiff.type`
1210 - :attr:`~AuditLogDiff.overwrites`
1211
1212 .. attribute:: overwrite_create
1213
1214 A channel permission overwrite was created.
1215
1216 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1217 the :class:`abc.GuildChannel` or :class:`Object` with an ID.
1218
1219 When this is the action, the type of :attr:`~AuditLogEntry.extra` is
1220 either a :class:`Role` or :class:`Member`. If the object is not found
1221 then it is a :class:`Object` with an ID being filled, a name, and a
1222 ``type`` attribute set to either ``'role'`` or ``'member'`` to help
1223 dictate what type of ID it is.
1224
1225 Possible attributes for :class:`AuditLogDiff`:
1226
1227 - :attr:`~AuditLogDiff.deny`
1228 - :attr:`~AuditLogDiff.allow`
1229 - :attr:`~AuditLogDiff.id`
1230 - :attr:`~AuditLogDiff.type`
1231
1232 .. attribute:: overwrite_update
1233
1234 A channel permission overwrite was changed, this is typically
1235 when the permission values change.
1236
1237 See :attr:`overwrite_create` for more information on how the
1238 :attr:`~AuditLogEntry.target` and :attr:`~AuditLogEntry.extra` fields
1239 are set.
1240
1241 Possible attributes for :class:`AuditLogDiff`:
1242
1243 - :attr:`~AuditLogDiff.deny`
1244 - :attr:`~AuditLogDiff.allow`
1245 - :attr:`~AuditLogDiff.id`
1246 - :attr:`~AuditLogDiff.type`
1247
1248 .. attribute:: overwrite_delete
1249
1250 A channel permission overwrite was deleted.
1251
1252 See :attr:`overwrite_create` for more information on how the
1253 :attr:`~AuditLogEntry.target` and :attr:`~AuditLogEntry.extra` fields
1254 are set.
1255
1256 Possible attributes for :class:`AuditLogDiff`:
1257
1258 - :attr:`~AuditLogDiff.deny`
1259 - :attr:`~AuditLogDiff.allow`
1260 - :attr:`~AuditLogDiff.id`
1261 - :attr:`~AuditLogDiff.type`
1262
1263 .. attribute:: kick
1264
1265 A member was kicked.
1266
1267 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1268 the :class:`User` who got kicked.
1269
1270 When this is the action, :attr:`~AuditLogEntry.changes` is empty.
1271
1272 .. attribute:: member_prune
1273
1274 A member prune was triggered.
1275
1276 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1277 set to ``None``.
1278
1279 When this is the action, the type of :attr:`~AuditLogEntry.extra` is
1280 set to an unspecified proxy object with two attributes:
1281
1282 - ``delete_members_days``: An integer specifying how far the prune was.
1283 - ``members_removed``: An integer specifying how many members were removed.
1284
1285 When this is the action, :attr:`~AuditLogEntry.changes` is empty.
1286
1287 .. attribute:: ban
1288
1289 A member was banned.
1290
1291 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1292 the :class:`User` who got banned.
1293
1294 When this is the action, :attr:`~AuditLogEntry.changes` is empty.
1295
1296 .. attribute:: unban
1297
1298 A member was unbanned.
1299
1300 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1301 the :class:`User` who got unbanned.
1302
1303 When this is the action, :attr:`~AuditLogEntry.changes` is empty.
1304
1305 .. attribute:: member_update
1306
1307 A member has updated. This triggers in the following situations:
1308
1309 - A nickname was changed
1310 - They were server muted or deafened (or it was undo'd)
1311
1312 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1313 the :class:`Member` or :class:`User` who got updated.
1314
1315 Possible attributes for :class:`AuditLogDiff`:
1316
1317 - :attr:`~AuditLogDiff.nick`
1318 - :attr:`~AuditLogDiff.mute`
1319 - :attr:`~AuditLogDiff.deaf`
1320
1321 .. attribute:: member_role_update
1322
1323 A member's role has been updated. This triggers when a member
1324 either gains a role or losses a role.
1325
1326 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1327 the :class:`Member` or :class:`User` who got the role.
1328
1329 Possible attributes for :class:`AuditLogDiff`:
1330
1331 - :attr:`~AuditLogDiff.roles`
1332
1333 .. attribute:: member_move
1334
1335 A member's voice channel has been updated. This triggers when a
1336 member is moved to a different voice channel.
1337
1338 When this is the action, the type of :attr:`~AuditLogEntry.extra` is
1339 set to an unspecified proxy object with two attributes:
1340
1341 - ``channel``: A :class:`TextChannel` or :class:`Object` with the channel ID where the members were moved.
1342 - ``count``: An integer specifying how many members were moved.
1343
1344 .. versionadded:: 1.3
1345
1346 .. attribute:: member_disconnect
1347
1348 A member's voice state has changed. This triggers when a
1349 member is force disconnected from voice.
1350
1351 When this is the action, the type of :attr:`~AuditLogEntry.extra` is
1352 set to an unspecified proxy object with one attribute:
1353
1354 - ``count``: An integer specifying how many members were disconnected.
1355
1356 .. versionadded:: 1.3
1357
1358 .. attribute:: bot_add
1359
1360 A bot was added to the guild.
1361
1362 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1363 the :class:`Member` or :class:`User` which was added to the guild.
1364
1365 .. versionadded:: 1.3
1366
1367 .. attribute:: role_create
1368
1369 A new role was created.
1370
1371 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1372 the :class:`Role` or a :class:`Object` with the ID.
1373
1374 Possible attributes for :class:`AuditLogDiff`:
1375
1376 - :attr:`~AuditLogDiff.colour`
1377 - :attr:`~AuditLogDiff.mentionable`
1378 - :attr:`~AuditLogDiff.hoist`
1379 - :attr:`~AuditLogDiff.name`
1380 - :attr:`~AuditLogDiff.permissions`
1381
1382 .. attribute:: role_update
1383
1384 A role was updated. This triggers in the following situations:
1385
1386 - The name has changed
1387 - The permissions have changed
1388 - The colour has changed
1389 - Its hoist/mentionable state has changed
1390
1391 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1392 the :class:`Role` or a :class:`Object` with the ID.
1393
1394 Possible attributes for :class:`AuditLogDiff`:
1395
1396 - :attr:`~AuditLogDiff.colour`
1397 - :attr:`~AuditLogDiff.mentionable`
1398 - :attr:`~AuditLogDiff.hoist`
1399 - :attr:`~AuditLogDiff.name`
1400 - :attr:`~AuditLogDiff.permissions`
1401
1402 .. attribute:: role_delete
1403
1404 A role was deleted.
1405
1406 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1407 the :class:`Role` or a :class:`Object` with the ID.
1408
1409 Possible attributes for :class:`AuditLogDiff`:
1410
1411 - :attr:`~AuditLogDiff.colour`
1412 - :attr:`~AuditLogDiff.mentionable`
1413 - :attr:`~AuditLogDiff.hoist`
1414 - :attr:`~AuditLogDiff.name`
1415 - :attr:`~AuditLogDiff.permissions`
1416
1417 .. attribute:: invite_create
1418
1419 An invite was created.
1420
1421 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1422 the :class:`Invite` that was created.
1423
1424 Possible attributes for :class:`AuditLogDiff`:
1425
1426 - :attr:`~AuditLogDiff.max_age`
1427 - :attr:`~AuditLogDiff.code`
1428 - :attr:`~AuditLogDiff.temporary`
1429 - :attr:`~AuditLogDiff.inviter`
1430 - :attr:`~AuditLogDiff.channel`
1431 - :attr:`~AuditLogDiff.uses`
1432 - :attr:`~AuditLogDiff.max_uses`
1433
1434 .. attribute:: invite_update
1435
1436 An invite was updated.
1437
1438 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1439 the :class:`Invite` that was updated.
1440
1441 .. attribute:: invite_delete
1442
1443 An invite was deleted.
1444
1445 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1446 the :class:`Invite` that was deleted.
1447
1448 Possible attributes for :class:`AuditLogDiff`:
1449
1450 - :attr:`~AuditLogDiff.max_age`
1451 - :attr:`~AuditLogDiff.code`
1452 - :attr:`~AuditLogDiff.temporary`
1453 - :attr:`~AuditLogDiff.inviter`
1454 - :attr:`~AuditLogDiff.channel`
1455 - :attr:`~AuditLogDiff.uses`
1456 - :attr:`~AuditLogDiff.max_uses`
1457
1458 .. attribute:: webhook_create
1459
1460 A webhook was created.
1461
1462 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1463 the :class:`Object` with the webhook ID.
1464
1465 Possible attributes for :class:`AuditLogDiff`:
1466
1467 - :attr:`~AuditLogDiff.channel`
1468 - :attr:`~AuditLogDiff.name`
1469 - :attr:`~AuditLogDiff.type` (always set to ``1`` if so)
1470
1471 .. attribute:: webhook_update
1472
1473 A webhook was updated. This trigger in the following situations:
1474
1475 - The webhook name changed
1476 - The webhook channel changed
1477
1478 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1479 the :class:`Object` with the webhook ID.
1480
1481 Possible attributes for :class:`AuditLogDiff`:
1482
1483 - :attr:`~AuditLogDiff.channel`
1484 - :attr:`~AuditLogDiff.name`
1485
1486 .. attribute:: webhook_delete
1487
1488 A webhook was deleted.
1489
1490 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1491 the :class:`Object` with the webhook ID.
1492
1493 Possible attributes for :class:`AuditLogDiff`:
1494
1495 - :attr:`~AuditLogDiff.channel`
1496 - :attr:`~AuditLogDiff.name`
1497 - :attr:`~AuditLogDiff.type` (always set to ``1`` if so)
1498
1499 .. attribute:: emoji_create
1500
1501 An emoji was created.
1502
1503 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1504 the :class:`Emoji` or :class:`Object` with the emoji ID.
1505
1506 Possible attributes for :class:`AuditLogDiff`:
1507
1508 - :attr:`~AuditLogDiff.name`
1509
1510 .. attribute:: emoji_update
1511
1512 An emoji was updated. This triggers when the name has changed.
1513
1514 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1515 the :class:`Emoji` or :class:`Object` with the emoji ID.
1516
1517 Possible attributes for :class:`AuditLogDiff`:
1518
1519 - :attr:`~AuditLogDiff.name`
1520
1521 .. attribute:: emoji_delete
1522
1523 An emoji was deleted.
1524
1525 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1526 the :class:`Object` with the emoji ID.
1527
1528 Possible attributes for :class:`AuditLogDiff`:
1529
1530 - :attr:`~AuditLogDiff.name`
1531
1532 .. attribute:: message_delete
1533
1534 A message was deleted by a moderator. Note that this
1535 only triggers if the message was deleted by someone other than the author.
1536
1537 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1538 the :class:`Member` or :class:`User` who had their message deleted.
1539
1540 When this is the action, the type of :attr:`~AuditLogEntry.extra` is
1541 set to an unspecified proxy object with two attributes:
1542
1543 - ``count``: An integer specifying how many messages were deleted.
1544 - ``channel``: A :class:`TextChannel` or :class:`Object` with the channel ID where the message got deleted.
1545
1546 .. attribute:: message_bulk_delete
1547
1548 Messages were bulk deleted by a moderator.
1549
1550 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1551 the :class:`TextChannel` or :class:`Object` with the ID of the channel that was purged.
1552
1553 When this is the action, the type of :attr:`~AuditLogEntry.extra` is
1554 set to an unspecified proxy object with one attribute:
1555
1556 - ``count``: An integer specifying how many messages were deleted.
1557
1558 .. versionadded:: 1.3
1559
1560 .. attribute:: message_pin
1561
1562 A message was pinned in a channel.
1563
1564 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1565 the :class:`Member` or :class:`User` who had their message pinned.
1566
1567 When this is the action, the type of :attr:`~AuditLogEntry.extra` is
1568 set to an unspecified proxy object with two attributes:
1569
1570 - ``channel``: A :class:`TextChannel` or :class:`Object` with the channel ID where the message was pinned.
1571 - ``message_id``: the ID of the message which was pinned.
1572
1573 .. versionadded:: 1.3
1574
1575 .. attribute:: message_unpin
1576
1577 A message was unpinned in a channel.
1578
1579 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1580 the :class:`Member` or :class:`User` who had their message unpinned.
1581
1582 When this is the action, the type of :attr:`~AuditLogEntry.extra` is
1583 set to an unspecified proxy object with two attributes:
1584
1585 - ``channel``: A :class:`TextChannel` or :class:`Object` with the channel ID where the message was unpinned.
1586 - ``message_id``: the ID of the message which was unpinned.
1587
1588 .. versionadded:: 1.3
1589
1590 .. attribute:: integration_create
1591
1592 A guild integration was created.
1593
1594 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1595 the :class:`Object` with the integration ID of the integration which was created.
1596
1597 .. versionadded:: 1.3
1598
1599 .. attribute:: integration_update
1600
1601 A guild integration was updated.
1602
1603 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1604 the :class:`Object` with the integration ID of the integration which was updated.
1605
1606 .. versionadded:: 1.3
1607
1608 .. attribute:: integration_delete
1609
1610 A guild integration was deleted.
1611
1612 When this is the action, the type of :attr:`~AuditLogEntry.target` is
1613 the :class:`Object` with the integration ID of the integration which was deleted.
1614
1615 .. versionadded:: 1.3
1616
1617.. class:: AuditLogActionCategory
1618
1619 Represents the category that the :class:`AuditLogAction` belongs to.
1620
1621 This can be retrieved via :attr:`AuditLogEntry.category`.
1622
1623 .. attribute:: create
1624
1625 The action is the creation of something.
1626
1627 .. attribute:: delete
1628
1629 The action is the deletion of something.
1630
1631 .. attribute:: update
1632
1633 The action is the update of something.
1634
1635
1636.. class:: RelationshipType
1637
1638 Specifies the type of :class:`Relationship`.
1639
1640 .. note::
1641
1642 This only applies to users, *not* bots.
1643
1644 .. attribute:: friend
1645
1646 You are friends with this user.
1647
1648 .. attribute:: blocked
1649
1650 You have blocked this user.
1651
1652 .. attribute:: incoming_request
1653
1654 The user has sent you a friend request.
1655
1656 .. attribute:: outgoing_request
1657
1658 You have sent a friend request to this user.
1659
1660
1661.. class:: UserContentFilter
1662
1663 Represents the options found in ``Settings > Privacy & Safety > Safe Direct Messaging``
1664 in the Discord client.
1665
1666 .. note::
1667
1668 This only applies to users, *not* bots.
1669
1670 .. attribute:: all_messages
1671
1672 Scan all direct messages from everyone.
1673
1674 .. attribute:: friends
1675
1676 Scan all direct messages that aren't from friends.
1677
1678 .. attribute:: disabled
1679
1680 Don't scan any direct messages.
1681
1682
1683.. class:: FriendFlags
1684
1685 Represents the options found in ``Settings > Privacy & Safety > Who Can Add You As A Friend``
1686 in the Discord client.
1687
1688 .. note::
1689
1690 This only applies to users, *not* bots.
1691
1692 .. attribute:: noone
1693
1694 This allows no-one to add you as a friend.
1695
1696 .. attribute:: mutual_guilds
1697
1698 This allows guild members to add you as a friend.
1699
1700 .. attribute:: mutual_friends
1701
1702 This allows friends of friends to add you as a friend.
1703
1704 .. attribute:: guild_and_friends
1705
1706 This is a superset of :attr:`mutual_guilds` and :attr:`mutual_friends`.
1707
1708 .. attribute:: everyone
1709
1710 This allows everyone to add you as a friend.
1711
1712
1713.. class:: PremiumType
1714
1715 Represents the user's Discord Nitro subscription type.
1716
1717 .. note::
1718
1719 This only applies to users, *not* bots.
1720
1721 .. attribute:: nitro
1722
1723 Represents the Discord Nitro with Nitro-exclusive games.
1724
1725 .. attribute:: nitro_classic
1726
1727 Represents the Discord Nitro with no Nitro-exclusive games.
1728
1729
1730.. class:: Theme
1731
1732 Represents the theme synced across all Discord clients.
1733
1734 .. note::
1735
1736 This only applies to users, *not* bots.
1737
1738 .. attribute:: light
1739
1740 Represents the Light theme on Discord.
1741
1742 .. attribute:: dark
1743
1744 Represents the Dark theme on Discord.
1745
1746
1747.. class:: TeamMembershipState
1748
1749 Represents the membership state of a team member retrieved through :func:`Bot.application_info`.
1750
1751 .. versionadded:: 1.3
1752
1753 .. attribute:: invited
1754
1755 Represents an invited member.
1756
1757 .. attribute:: accepted
1758
1759 Represents a member currently in the team.
1760
1761.. class:: WebhookType
1762
1763 Represents the type of webhook that can be received.
1764
1765 .. versionadded:: 1.3
1766
1767 .. attribute:: incoming
1768
1769 Represents a webhook that can post messages to channels with a token.
1770
1771 .. attribute:: channel_follower
1772
1773 Represents a webhook that is internally managed by Discord, used for following channels.
1774
1775Async Iterator
1776----------------
1777
1778Some API functions return an "async iterator". An async iterator is something that is
1779capable of being used in an :ref:`async for statement <py:async for>`.
1780
1781These async iterators can be used as follows: ::
1782
1783 async for elem in channel.history():
1784 # do stuff with elem here
1785
1786Certain utilities make working with async iterators easier, detailed below.
1787
1788.. class:: AsyncIterator
1789
1790 Represents the "AsyncIterator" concept. Note that no such class exists,
1791 it is purely abstract.
1792
1793 .. container:: operations
1794
1795 .. describe:: async for x in y
1796
1797 Iterates over the contents of the async iterator.
1798
1799
1800 .. method:: next()
1801 :async:
1802
1803 |coro|
1804
1805 Advances the iterator by one, if possible. If no more items are found
1806 then this raises :exc:`NoMoreItems`.
1807
1808 .. method:: get(**attrs)
1809 :async:
1810
1811 |coro|
1812
1813 Similar to :func:`utils.get` except run over the async iterator.
1814
1815 Getting the last message by a user named 'Dave' or ``None``: ::
1816
1817 msg = await channel.history().get(author__name='Dave')
1818
1819 .. method:: find(predicate)
1820 :async:
1821
1822 |coro|
1823
1824 Similar to :func:`utils.find` except run over the async iterator.
1825
1826 Unlike :func:`utils.find`\, the predicate provided can be a
1827 |coroutine_link|_.
1828
1829 Getting the last audit log with a reason or ``None``: ::
1830
1831 def predicate(event):
1832 return event.reason is not None
1833
1834 event = await guild.audit_logs().find(predicate)
1835
1836 :param predicate: The predicate to use. Could be a |coroutine_link|_.
1837 :return: The first element that returns ``True`` for the predicate or ``None``.
1838
1839 .. method:: flatten()
1840 :async:
1841
1842 |coro|
1843
1844 Flattens the async iterator into a :class:`list` with all the elements.
1845
1846 :return: A list of every element in the async iterator.
1847 :rtype: list
1848
1849 .. method:: map(func)
1850
1851 This is similar to the built-in :func:`map <py:map>` function. Another
1852 :class:`AsyncIterator` is returned that executes the function on
1853 every element it is iterating over. This function can either be a
1854 regular function or a |coroutine_link|_.
1855
1856 Creating a content iterator: ::
1857
1858 def transform(message):
1859 return message.content
1860
1861 async for content in channel.history().map(transform):
1862 message_length = len(content)
1863
1864 :param func: The function to call on every element. Could be a |coroutine_link|_.
1865 :return: An async iterator.
1866
1867 .. method:: filter(predicate)
1868
1869 This is similar to the built-in :func:`filter <py:filter>` function. Another
1870 :class:`AsyncIterator` is returned that filters over the original
1871 async iterator. This predicate can be a regular function or a |coroutine_link|_.
1872
1873 Getting messages by non-bot accounts: ::
1874
1875 def predicate(message):
1876 return not message.author.bot
1877
1878 async for elem in channel.history().filter(predicate):
1879 ...
1880
1881 :param predicate: The predicate to call on every element. Could be a |coroutine_link|_.
1882 :return: An async iterator.
1883
1884.. _discord-api-audit-logs:
1885
1886Audit Log Data
1887----------------
1888
1889Working with :meth:`Guild.audit_logs` is a complicated process with a lot of machinery
1890involved. The library attempts to make it easy to use and friendly. In order to accomplish
1891this goal, it must make use of a couple of data classes that aid in this goal.
1892
1893.. autoclass:: AuditLogEntry
1894 :members:
1895
1896.. class:: AuditLogChanges
1897
1898 An audit log change set.
1899
1900 .. attribute:: before
1901
1902 The old value. The attribute has the type of :class:`AuditLogDiff`.
1903
1904 Depending on the :class:`AuditLogActionCategory` retrieved by
1905 :attr:`~AuditLogEntry.category`\, the data retrieved by this
1906 attribute differs:
1907
1908 +----------------------------------------+---------------------------------------------------+
1909 | Category | Description |
1910 +----------------------------------------+---------------------------------------------------+
1911 | :attr:`~AuditLogActionCategory.create` | All attributes are set to ``None``. |
1912 +----------------------------------------+---------------------------------------------------+
1913 | :attr:`~AuditLogActionCategory.delete` | All attributes are set the value before deletion. |
1914 +----------------------------------------+---------------------------------------------------+
1915 | :attr:`~AuditLogActionCategory.update` | All attributes are set the value before updating. |
1916 +----------------------------------------+---------------------------------------------------+
1917 | ``None`` | No attributes are set. |
1918 +----------------------------------------+---------------------------------------------------+
1919
1920 .. attribute:: after
1921
1922 The new value. The attribute has the type of :class:`AuditLogDiff`.
1923
1924 Depending on the :class:`AuditLogActionCategory` retrieved by
1925 :attr:`~AuditLogEntry.category`\, the data retrieved by this
1926 attribute differs:
1927
1928 +----------------------------------------+--------------------------------------------------+
1929 | Category | Description |
1930 +----------------------------------------+--------------------------------------------------+
1931 | :attr:`~AuditLogActionCategory.create` | All attributes are set to the created value |
1932 +----------------------------------------+--------------------------------------------------+
1933 | :attr:`~AuditLogActionCategory.delete` | All attributes are set to ``None`` |
1934 +----------------------------------------+--------------------------------------------------+
1935 | :attr:`~AuditLogActionCategory.update` | All attributes are set the value after updating. |
1936 +----------------------------------------+--------------------------------------------------+
1937 | ``None`` | No attributes are set. |
1938 +----------------------------------------+--------------------------------------------------+
1939
1940.. class:: AuditLogDiff
1941
1942 Represents an audit log "change" object. A change object has dynamic
1943 attributes that depend on the type of action being done. Certain actions
1944 map to certain attributes being set.
1945
1946 Note that accessing an attribute that does not match the specified action
1947 will lead to an attribute error.
1948
1949 To get a list of attributes that have been set, you can iterate over
1950 them. To see a list of all possible attributes that could be set based
1951 on the action being done, check the documentation for :class:`AuditLogAction`,
1952 otherwise check the documentation below for all attributes that are possible.
1953
1954 .. describe:: iter(diff)
1955
1956 Returns an iterator over (attribute, value) tuple of this diff.
1957
1958 .. attribute:: name
1959
1960 :class:`str` – A name of something.
1961
1962 .. attribute:: icon
1963
1964 :class:`str` – A guild's icon hash. See also :attr:`Guild.icon`.
1965
1966 .. attribute:: splash
1967
1968 :class:`str` – The guild's invite splash hash. See also :attr:`Guild.splash`.
1969
1970 .. attribute:: owner
1971
1972 Union[:class:`Member`, :class:`User`] – The guild's owner. See also :attr:`Guild.owner`
1973
1974 .. attribute:: region
1975
1976 :class:`VoiceRegion` – The guild's voice region. See also :attr:`Guild.region`.
1977
1978 .. attribute:: afk_channel
1979
1980 Union[:class:`VoiceChannel`, :class:`Object`] – The guild's AFK channel.
1981
1982 If this could not be found, then it falls back to a :class:`Object`
1983 with the ID being set.
1984
1985 See :attr:`Guild.afk_channel`.
1986
1987 .. attribute:: system_channel
1988
1989 Union[:class:`TextChannel`, :class:`Object`] – The guild's system channel.
1990
1991 If this could not be found, then it falls back to a :class:`Object`
1992 with the ID being set.
1993
1994 See :attr:`Guild.system_channel`.
1995
1996 .. attribute:: afk_timeout
1997
1998 :class:`int` – The guild's AFK timeout. See :attr:`Guild.afk_timeout`.
1999
2000 .. attribute:: mfa_level
2001
2002 :class:`int` - The guild's MFA level. See :attr:`Guild.mfa_level`.
2003
2004 .. attribute:: widget_enabled
2005
2006 :class:`bool` – The guild's widget has been enabled or disabled.
2007
2008 .. attribute:: widget_channel
2009
2010 Union[:class:`TextChannel`, :class:`Object`] – The widget's channel.
2011
2012 If this could not be found then it falls back to a :class:`Object`
2013 with the ID being set.
2014
2015 .. attribute:: verification_level
2016
2017 :class:`VerificationLevel` – The guild's verification level.
2018
2019 See also :attr:`Guild.verification_level`.
2020
2021 .. attribute:: default_notifications
2022
2023 :class:`NotificationLevel` – The guild's default notification level.
2024
2025 See also :attr:`Guild.default_notifications`.
2026
2027 .. attribute:: explicit_content_filter
2028
2029 :class:`ContentFilter` – The guild's content filter.
2030
2031 See also :attr:`Guild.explicit_content_filter`.
2032
2033 .. attribute:: default_message_notifications
2034
2035 :class:`int` – The guild's default message notification setting.
2036
2037 .. attribute:: vanity_url_code
2038
2039 :class:`str` – The guild's vanity URL.
2040
2041 See also :meth:`Guild.vanity_invite` and :meth:`Guild.edit`.
2042
2043 .. attribute:: position
2044
2045 :class:`int` – The position of a :class:`Role` or :class:`abc.GuildChannel`.
2046
2047 .. attribute:: type
2048
2049 Union[:class:`int`, :class:`str`] – The type of channel or channel permission overwrite.
2050
2051 If the type is an :class:`int`, then it is a type of channel which can be either
2052 ``0`` to indicate a text channel or ``1`` to indicate a voice channel.
2053
2054 If the type is a :class:`str`, then it is a type of permission overwrite which
2055 can be either ``'role'`` or ``'member'``.
2056
2057 .. attribute:: topic
2058
2059 :class:`str` – The topic of a :class:`TextChannel`.
2060
2061 See also :attr:`TextChannel.topic`.
2062
2063 .. attribute:: bitrate
2064
2065 :class:`int` – The bitrate of a :class:`VoiceChannel`.
2066
2067 See also :attr:`VoiceChannel.bitrate`.
2068
2069 .. attribute:: overwrites
2070
2071 List[Tuple[target, :class:`PermissionOverwrite`]] – A list of
2072 permission overwrite tuples that represents a target and a
2073 :class:`PermissionOverwrite` for said target.
2074
2075 The first element is the object being targeted, which can either
2076 be a :class:`Member` or :class:`User` or :class:`Role`. If this object
2077 is not found then it is a :class:`Object` with an ID being filled and
2078 a ``type`` attribute set to either ``'role'`` or ``'member'`` to help
2079 decide what type of ID it is.
2080
2081 .. attribute:: roles
2082
2083 List[Union[:class:`Role`, :class:`Object`]] – A list of roles being added or removed
2084 from a member.
2085
2086 If a role is not found then it is a :class:`Object` with the ID and name being
2087 filled in.
2088
2089 .. attribute:: nick
2090
2091 Optional[:class:`str`] – The nickname of a member.
2092
2093 See also :attr:`Member.nick`
2094
2095 .. attribute:: deaf
2096
2097 :class:`bool` – Whether the member is being server deafened.
2098
2099 See also :attr:`VoiceState.deaf`.
2100
2101 .. attribute:: mute
2102
2103 :class:`bool` – Whether the member is being server muted.
2104
2105 See also :attr:`VoiceState.mute`.
2106
2107 .. attribute:: permissions
2108
2109 :class:`Permissions` – The permissions of a role.
2110
2111 See also :attr:`Role.permissions`.
2112
2113 .. attribute:: colour
2114 color
2115
2116 :class:`Colour` – The colour of a role.
2117
2118 See also :attr:`Role.colour`
2119
2120 .. attribute:: hoist
2121
2122 :class:`bool` – Whether the role is being hoisted or not.
2123
2124 See also :attr:`Role.hoist`
2125
2126 .. attribute:: mentionable
2127
2128 :class:`bool` – Whether the role is mentionable or not.
2129
2130 See also :attr:`Role.mentionable`
2131
2132 .. attribute:: code
2133
2134 :class:`str` – The invite's code.
2135
2136 See also :attr:`Invite.code`
2137
2138 .. attribute:: channel
2139
2140 Union[:class:`abc.GuildChannel`, :class:`Object`] – A guild channel.
2141
2142 If the channel is not found then it is a :class:`Object` with the ID
2143 being set. In some cases the channel name is also set.
2144
2145 .. attribute:: inviter
2146
2147 :class:`User` – The user who created the invite.
2148
2149 See also :attr:`Invite.inviter`.
2150
2151 .. attribute:: max_uses
2152
2153 :class:`int` – The invite's max uses.
2154
2155 See also :attr:`Invite.max_uses`.
2156
2157 .. attribute:: uses
2158
2159 :class:`int` – The invite's current uses.
2160
2161 See also :attr:`Invite.uses`.
2162
2163 .. attribute:: max_age
2164
2165 :class:`int` – The invite's max age in seconds.
2166
2167 See also :attr:`Invite.max_age`.
2168
2169 .. attribute:: temporary
2170
2171 :class:`bool` – If the invite is a temporary invite.
2172
2173 See also :attr:`Invite.temporary`.
2174
2175 .. attribute:: allow
2176 deny
2177
2178 :class:`Permissions` – The permissions being allowed or denied.
2179
2180 .. attribute:: id
2181
2182 :class:`int` – The ID of the object being changed.
2183
2184 .. attribute:: avatar
2185
2186 :class:`str` – The avatar hash of a member.
2187
2188 See also :attr:`User.avatar`.
2189
2190 .. attribute:: slowmode_delay
2191
2192 :class:`int` – The number of seconds members have to wait before
2193 sending another message in the channel.
2194
2195 See also :attr:`TextChannel.slowmode_delay`.
2196
2197.. this is currently missing the following keys: reason and application_id
2198 I'm not sure how to about porting these
2199
2200Webhook Support
2201------------------
2202
2203discord.py offers support for creating, editing, and executing webhooks through the :class:`Webhook` class.
2204
2205.. autoclass:: Webhook
2206 :members:
2207
2208Adapters
2209~~~~~~~~~
2210
2211Adapters allow you to change how the request should be handled. They all build on a single
2212interface, :meth:`WebhookAdapter.request`.
2213
2214.. autoclass:: WebhookAdapter
2215 :members:
2216
2217.. autoclass:: AsyncWebhookAdapter
2218 :members:
2219
2220.. autoclass:: RequestsWebhookAdapter
2221 :members:
2222
2223.. _discord_api_abcs:
2224
2225Abstract Base Classes
2226-----------------------
2227
2228An :term:`py:abstract base class` (also known as an ``abc``) is a class that models can inherit
2229to get their behaviour. The Python implementation of an :doc:`abc <py:library/abc>` is
2230slightly different in that you can register them at run-time. **Abstract base classes cannot be instantiated**.
2231They are mainly there for usage with :func:`py:isinstance` and :func:`py:issubclass`\.
2232
2233This library has a module related to abstract base classes, some of which are actually from the :doc:`abc <py:library/abc>` standard
2234module, others which are not.
2235
2236.. autoclass:: discord.abc.Snowflake
2237 :members:
2238
2239.. autoclass:: discord.abc.User
2240 :members:
2241
2242.. autoclass:: discord.abc.PrivateChannel
2243 :members:
2244
2245.. autoclass:: discord.abc.GuildChannel
2246 :members:
2247
2248.. autoclass:: discord.abc.Messageable
2249 :members:
2250 :exclude-members: history, typing
2251
2252 .. automethod:: discord.abc.Messageable.history
2253 :async-for:
2254
2255 .. automethod:: discord.abc.Messageable.typing
2256 :async-with:
2257
2258.. autoclass:: discord.abc.Connectable
2259
2260.. _discord_api_models:
2261
2262Discord Models
2263---------------
2264
2265Models are classes that are received from Discord and are not meant to be created by
2266the user of the library.
2267
2268.. danger::
2269
2270 The classes listed below are **not intended to be created by users** and are also
2271 **read-only**.
2272
2273 For example, this means that you should not make your own :class:`User` instances
2274 nor should you modify the :class:`User` instance yourself.
2275
2276 If you want to get one of these model classes instances they'd have to be through
2277 the cache, and a common way of doing so is through the :func:`utils.find` function
2278 or attributes of model classes that you receive from the events specified in the
2279 :ref:`discord-api-events`.
2280
2281.. note::
2282
2283 Nearly all classes here have :ref:`py:slots` defined which means that it is
2284 impossible to have dynamic attributes to the data classes.
2285
2286
2287ClientUser
2288~~~~~~~~~~~~
2289
2290.. autoclass:: ClientUser()
2291 :members:
2292 :inherited-members:
2293
2294Relationship
2295~~~~~~~~~~~~~~
2296
2297.. autoclass:: Relationship()
2298 :members:
2299
2300User
2301~~~~~
2302
2303.. autoclass:: User()
2304 :members:
2305 :inherited-members:
2306 :exclude-members: history, typing
2307
2308 .. automethod:: history
2309 :async-for:
2310
2311 .. automethod:: typing
2312 :async-with:
2313
2314Attachment
2315~~~~~~~~~~~
2316
2317.. autoclass:: Attachment()
2318 :members:
2319
2320Asset
2321~~~~~
2322
2323.. autoclass:: Asset()
2324 :members:
2325
2326Message
2327~~~~~~~
2328
2329.. autoclass:: Message()
2330 :members:
2331
2332Reaction
2333~~~~~~~~~
2334
2335.. autoclass:: Reaction()
2336 :members:
2337 :exclude-members: users
2338
2339 .. automethod:: users
2340 :async-for:
2341
2342CallMessage
2343~~~~~~~~~~~~
2344
2345.. autoclass:: CallMessage()
2346 :members:
2347
2348GroupCall
2349~~~~~~~~~~
2350
2351.. autoclass:: GroupCall()
2352 :members:
2353
2354Guild
2355~~~~~~
2356
2357.. autoclass:: Guild()
2358 :members:
2359 :exclude-members: audit_logs
2360
2361 .. automethod:: audit_logs
2362 :async-for:
2363
2364Member
2365~~~~~~
2366
2367.. autoclass:: Member()
2368 :members:
2369 :inherited-members:
2370 :exclude-members: history, typing
2371
2372 .. automethod:: history
2373 :async-for:
2374
2375 .. automethod:: typing
2376 :async-with:
2377
2378Spotify
2379~~~~~~~~
2380
2381.. autoclass:: Spotify()
2382 :members:
2383
2384VoiceState
2385~~~~~~~~~~~
2386
2387.. autoclass:: VoiceState()
2388 :members:
2389
2390Emoji
2391~~~~~
2392
2393.. autoclass:: Emoji()
2394 :members:
2395
2396PartialEmoji
2397~~~~~~~~~~~~~~~~~~~~~~
2398
2399.. autoclass:: PartialEmoji()
2400 :members:
2401
2402Role
2403~~~~~
2404
2405.. autoclass:: Role()
2406 :members:
2407
2408TextChannel
2409~~~~~~~~~~~~
2410
2411.. autoclass:: TextChannel()
2412 :members:
2413 :inherited-members:
2414 :exclude-members: history, typing
2415
2416 .. automethod:: history
2417 :async-for:
2418
2419 .. automethod:: typing
2420 :async-with:
2421
2422VoiceChannel
2423~~~~~~~~~~~~~
2424
2425.. autoclass:: VoiceChannel()
2426 :members:
2427 :inherited-members:
2428
2429CategoryChannel
2430~~~~~~~~~~~~~~~~~
2431
2432.. autoclass:: CategoryChannel()
2433 :members:
2434 :inherited-members:
2435
2436DMChannel
2437~~~~~~~~~
2438
2439.. autoclass:: DMChannel()
2440 :members:
2441 :inherited-members:
2442 :exclude-members: history, typing
2443
2444 .. automethod:: history
2445 :async-for:
2446
2447 .. automethod:: typing
2448 :async-with:
2449
2450GroupChannel
2451~~~~~~~~~~~~
2452
2453.. autoclass:: GroupChannel()
2454 :members:
2455 :inherited-members:
2456 :exclude-members: history, typing
2457
2458 .. automethod:: history
2459 :async-for:
2460
2461 .. automethod:: typing
2462 :async-with:
2463
2464PartialInviteGuild
2465~~~~~~~~~~~~~~~~~~~
2466
2467.. autoclass:: PartialInviteGuild()
2468 :members:
2469
2470PartialInviteChannel
2471~~~~~~~~~~~~~~~~~~~~~
2472
2473.. autoclass:: PartialInviteChannel()
2474 :members:
2475
2476Invite
2477~~~~~~~
2478
2479.. autoclass:: Invite()
2480 :members:
2481
2482WidgetChannel
2483~~~~~~~~~~~~~~~
2484
2485.. autoclass:: WidgetChannel()
2486 :members:
2487
2488WidgetMember
2489~~~~~~~~~~~~~
2490
2491.. autoclass:: WidgetMember()
2492 :members:
2493 :inherited-members:
2494
2495Widget
2496~~~~~~~
2497
2498.. autoclass:: Widget()
2499 :members:
2500
2501RawMessageDeleteEvent
2502~~~~~~~~~~~~~~~~~~~~~~~
2503
2504.. autoclass:: RawMessageDeleteEvent()
2505 :members:
2506
2507RawBulkMessageDeleteEvent
2508~~~~~~~~~~~~~~~~~~~~~~~~~~
2509
2510.. autoclass:: RawBulkMessageDeleteEvent()
2511 :members:
2512
2513RawMessageUpdateEvent
2514~~~~~~~~~~~~~~~~~~~~~~
2515
2516.. autoclass:: RawMessageUpdateEvent()
2517 :members:
2518
2519RawReactionActionEvent
2520~~~~~~~~~~~~~~~~~~~~~~~
2521
2522.. autoclass:: RawReactionActionEvent()
2523 :members:
2524
2525RawReactionClearEvent
2526~~~~~~~~~~~~~~~~~~~~~~
2527
2528.. autoclass:: RawReactionClearEvent()
2529 :members:
2530
2531RawReactionClearEmojiEvent
2532~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2533
2534.. autoclass:: RawReactionClearEmojiEvent()
2535 :members:
2536
2537
2538.. _discord_api_data:
2539
2540Data Classes
2541--------------
2542
2543Some classes are just there to be data containers, this lists them.
2544
2545Unlike :ref:`models <discord_api_models>` you are allowed to create
2546these yourself, even if they can also be used to hold attributes.
2547
2548Nearly all classes here have :ref:`py:slots` defined which means that it is
2549impossible to have dynamic attributes to the data classes.
2550
2551The only exception to this rule is :class:`abc.Snowflake`, which is made with
2552dynamic attributes in mind.
2553
2554
2555Object
2556~~~~~~~
2557
2558.. autoclass:: Object
2559 :members:
2560
2561Embed
2562~~~~~~
2563
2564.. autoclass:: Embed
2565 :members:
2566
2567File
2568~~~~~
2569
2570.. autoclass:: File
2571 :members:
2572
2573Colour
2574~~~~~~
2575
2576.. autoclass:: Colour
2577 :members:
2578
2579BaseActivity
2580~~~~~~~~~~~~~~
2581
2582.. autoclass:: BaseActivity
2583 :members:
2584
2585Activity
2586~~~~~~~~~
2587
2588.. autoclass:: Activity
2589 :members:
2590
2591Game
2592~~~~~
2593
2594.. autoclass:: Game
2595 :members:
2596
2597Streaming
2598~~~~~~~~~~~
2599
2600.. autoclass:: Streaming
2601 :members:
2602
2603CustomActivity
2604~~~~~~~~~~~~~~~
2605
2606.. autoclass:: CustomActivity
2607 :members:
2608
2609Permissions
2610~~~~~~~~~~~~
2611
2612.. autoclass:: Permissions
2613 :members:
2614
2615PermissionOverwrite
2616~~~~~~~~~~~~~~~~~~~~
2617
2618.. autoclass:: PermissionOverwrite
2619 :members:
2620
2621SystemChannelFlags
2622~~~~~~~~~~~~~~~~~~~~
2623
2624.. autoclass:: SystemChannelFlags
2625 :members:
2626
2627MessageFlags
2628~~~~~~~~~~~~
2629
2630.. autoclass:: MessageFlags
2631 :members:
2632
2633
2634Exceptions
2635------------
2636
2637The following exceptions are thrown by the library.
2638
2639.. autoexception:: DiscordException
2640
2641.. autoexception:: ClientException
2642
2643.. autoexception:: LoginFailure
2644
2645.. autoexception:: NoMoreItems
2646
2647.. autoexception:: HTTPException
2648 :members:
2649
2650.. autoexception:: Forbidden
2651
2652.. autoexception:: NotFound
2653
2654.. autoexception:: InvalidData
2655
2656.. autoexception:: InvalidArgument
2657
2658.. autoexception:: GatewayNotFound
2659
2660.. autoexception:: ConnectionClosed
2661
2662.. autoexception:: discord.opus.OpusError
2663
2664.. autoexception:: discord.opus.OpusNotLoaded
2665
2666Exception Hierarchy
2667~~~~~~~~~~~~~~~~~~~~~
2668
2669.. exception_hierarchy::
2670
2671 - :exc:`Exception`
2672 - :exc:`DiscordException`
2673 - :exc:`ClientException`
2674 - :exc:`InvalidData`
2675 - :exc:`InvalidArgument`
2676 - :exc:`LoginFailure`
2677 - :exc:`ConnectionClosed`
2678 - :exc:`NoMoreItems`
2679 - :exc:`GatewayNotFound`
2680 - :exc:`HTTPException`
2681 - :exc:`Forbidden`
2682 - :exc:`NotFound`