API Reference¶
The following section outlines the API of discord.py.
Note
This module uses the Python logging module to log diagnostic and errors in an output independent way. If the logging module is not configured, these logs will not be output anywhere. See Setting Up Logging for more information on how to set up and use the logging module with discord.py.
Clients¶
Client¶
- asyncapplication_info
- asyncbefore_identify_hook
- asyncchange_presence
- defclear
- asyncclose
- asyncconnect
- asynccreate_guild
- asyncdelete_invite
- @event
- asyncfetch_channel
- asyncfetch_guild
- deffetch_guilds
- asyncfetch_invite
- asyncfetch_template
- asyncfetch_user
- asyncfetch_user_profile
- asyncfetch_webhook
- asyncfetch_widget
- defget_all_channels
- defget_all_members
- defget_channel
- defget_emoji
- defget_guild
- defget_user
- defis_closed
- defis_ready
- defis_ws_ratelimited
- asynclogin
- asynclogout
- asyncon_error
- asyncrequest_offline_members
- defrun
- asyncstart
- asyncwait_for
- asyncwait_until_ready
-
class
discord.
Client
(*, loop=None, **options)¶ Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
A number of options can be passed to the
Client
.- Parameters:
max_messages (Optional[
int
]) –The maximum number of messages to store in the internal message cache. This defaults to
1000
. Passing inNone
disables the message cache.Changed in version 1.3: Allow disabling the message cache and change the default size to
1000
.loop (Optional[
asyncio.AbstractEventLoop
]) – Theasyncio.AbstractEventLoop
to use for asynchronous operations. Defaults toNone
, in which case the default event loop is used viaasyncio.get_event_loop()
.connector (
aiohttp.BaseConnector
) – The connector to use for connection pooling.proxy (Optional[
str
]) – Proxy URL.proxy_auth (Optional[
aiohttp.BasicAuth
]) – An object that represents proxy HTTP Basic Authorization.shard_id (Optional[
int
]) – Integer starting at0
and less thanshard_count
.shard_count (Optional[
int
]) – The total number of shards.intents (
Intents
) –The intents that you want to enable for the session. This is a way of disabling and enabling certain gateway events from triggering and being sent. If not given, defaults to a regularly constructed
Intents
class.New in version 1.5.
member_cache_flags (
MemberCacheFlags
) –Allows for finer control over how the library caches members. If not given, defaults to cache as much as possible with the currently selected intents.
New in version 1.5.
fetch_offline_members (
bool
) – A deprecated alias ofchunk_guilds_at_startup
.chunk_guilds_at_startup (
bool
) –Indicates if
on_ready()
should be delayed to chunk all guilds at start-up if necessary. This operation is incredibly slow for large amounts of guilds. The default isTrue
ifIntents.members
isTrue
.New in version 1.5.
status (Optional[
Status
]) – A status to start your presence with upon logging on to Discord.activity (Optional[
BaseActivity
]) – An activity to start your presence with upon logging on to Discord.allowed_mentions (Optional[
AllowedMentions
]) –Control how the client handles mentions by default on every message sent.
New in version 1.4.
heartbeat_timeout (
float
) – The maximum numbers of seconds before timing out and restarting the WebSocket in the case of not receiving a HEARTBEAT_ACK. Useful if processing the initial packets take too long to the point of disconnecting you. The default timeout is 60 seconds.guild_ready_timeout (
float
) –The maximum number of seconds to wait for the GUILD_CREATE stream to end before preparing the member cache and firing READY. The default timeout is 2 seconds.
New in version 1.4.
guild_subscriptions (
bool
) –Whether to dispatch presence or typing events. Defaults to
True
.New in version 1.3.
Warning
If this is set to
False
then the following features will be disabled:No user related updates (
on_user_update()
will not dispatch)- All member related events will be disabled.
Typing events will be disabled (
on_typing()
).If
fetch_offline_members
is set toFalse
then the user cache will not exist. This makes it difficult or impossible to do many things, for example:Computing permissions
Querying members in a voice channel via
VoiceChannel.members
will be empty.Most forms of receiving
Member
will be receivingUser
instead, except for message events.Guild.owner
will usually resolve toNone
.Guild.get_member()
will usually be unavailable.Anything that involves using
Member
.users
will not be as populated.etc.
In short, this makes it so the only member you can reliably query is the message author. Useful for bots that do not require any state.
assume_unsync_clock (
bool
) –Whether to assume the system clock is unsynced. This applies to the ratelimit handling code. If this is set to
True
, the default, then the library uses the time to reset a rate limit bucket given by Discord. If this isFalse
then your system clock is used to calculate how long to sleep for. If this is set toFalse
it is recommended to sync your system clock to Google’s NTP server.New in version 1.3.
-
ws
¶ The websocket gateway the client is currently connected to. Could be
None
.
-
loop
¶ The event loop that the client uses for HTTP requests and websocket operations.
-
async for ... in
fetch_guilds
(*, limit=100, before=None, after=None)¶ Retrieves an
AsyncIterator
that enables receiving your guilds.Note
Using this, you will only receive
Guild.owner
,Guild.icon
,Guild.id
, andGuild.name
perGuild
.Note
This method is an API call. For general usage, consider
guilds
instead.Examples
Usage
async for guild in client.fetch_guilds(limit=150): print(guild.name)
Flattening into a list
guilds = await client.fetch_guilds(limit=150).flatten() # guilds is now a list of Guild...
All parameters are optional.
- Parameters:
limit (Optional[
int
]) – The number of guilds to retrieve. IfNone
, it retrieves every guild you have access to. Note, however, that this would make it a slow operation. Defaults to100
.before (Union[
abc.Snowflake
,datetime.datetime
]) – Retrieves guilds before this date or object. If a date is provided it must be a timezone-naive datetime representing UTC time.after (Union[
abc.Snowflake
,datetime.datetime
]) – Retrieve guilds after this date or object. If a date is provided it must be a timezone-naive datetime representing UTC time.
- Raises:
HTTPException – Getting the guilds failed.
- Yields:
Guild
– The guild with the guild data parsed.
-
latency
¶ Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
- Type:
-
is_ws_ratelimited
()¶ bool
: Whether the websocket is currently rate limited.This can be useful to know when deciding whether you should query members using HTTP or via the gateway.
New in version 1.6.
-
user
¶ Represents the connected client.
None
if not logged in.- Type:
Optional[
ClientUser
]
-
cached_messages
¶ Read-only list of messages the connected client has cached.
New in version 1.1.
- Type:
Sequence[
Message
]
-
private_channels
¶ The private channels that the connected client is participating on.
Note
This returns only up to 128 most recent private channels due to an internal working on how Discord deals with private channels.
- Type:
List[
abc.PrivateChannel
]
-
voice_clients
¶ Represents a list of voice connections.
These are usually
VoiceClient
instances.- Type:
List[
VoiceProtocol
]
-
await
on_error
(event_method, *args, **kwargs)¶ This function is a coroutine.
The default error handler provided by the client.
By default this prints to
sys.stderr
however it could be overridden to have a different implementation. Checkon_error()
for more details.
-
await
request_offline_members
(*guilds)¶ This function is a coroutine.
Requests previously offline members from the guild to be filled up into the
Guild.members
cache. This function is usually not called. It should only be used if you have thefetch_offline_members
parameter set toFalse
.When the client logs on and connects to the websocket, Discord does not provide the library with offline members if the number of members in the guild is larger than 250. You can check if a guild is large if
Guild.large
isTrue
.Warning
This method is deprecated. Use
Guild.chunk()
instead.- Parameters:
*guilds (
Guild
) – An argument list of guilds to request offline members for.- Raises:
InvalidArgument – If any guild is unavailable in the collection.
-
await
before_identify_hook
(shard_id, *, initial=False)¶ This function is a coroutine.
A hook that is called before IDENTIFYing a session. This is useful if you wish to have more control over the synchronization of multiple IDENTIFYing clients.
The default implementation sleeps for 5 seconds.
New in version 1.4.
-
await
login
(token, *, bot=True)¶ This function is a coroutine.
Logs in the client with the specified credentials.
This function can be used in two different ways.
Warning
Logging on with a user token is against the Discord Terms of Service and doing so might potentially get your account banned. Use this at your own risk.
- Parameters:
- Raises:
LoginFailure – The wrong credentials are passed.
HTTPException – An unknown HTTP related error occurred, usually when it isn’t 200 or the known incorrect credentials passing status code.
-
await
logout
()¶ This function is a coroutine.
Logs out of Discord and closes all connections.
Deprecated since version 1.7.
Note
This is just an alias to
close()
. If you want to do extraneous cleanup when subclassing, it is suggested to overrideclose()
instead.-
await
connect
(*, reconnect=True)¶ This function is a coroutine.
Creates a websocket connection and lets the websocket listen to messages from Discord. This is a loop that runs the entire event system and miscellaneous aspects of the library. Control is not resumed until the WebSocket connection is terminated.
- Parameters:
reconnect (
bool
) – If we should attempt reconnecting, either due to internet failure or a specific failure on Discord’s part. Certain disconnects that lead to bad state will not be handled (such as invalid sharding payloads or bad tokens).- Raises:
GatewayNotFound – If the gateway to connect to Discord is not found. Usually if this is thrown then there is a Discord API outage.
ConnectionClosed – The websocket connection has been terminated.
-
clear
()¶ Clears the internal state of the bot.
After this, the bot can be considered “re-opened”, i.e.
is_closed()
andis_ready()
both returnFalse
along with the bot’s internal cache cleared.
-
await
start
(*args, **kwargs)¶ This function is a coroutine.
A shorthand coroutine for
login()
+connect()
.- Raises:
TypeError – An unexpected keyword argument was received.
-
run
(*args, **kwargs)¶ A blocking call that abstracts away the event loop initialisation from you.
If you want more control over the event loop then this function should not be used. Use
start()
coroutine orconnect()
+login()
.Roughly Equivalent to:
try: loop.run_until_complete(start(*args, **kwargs)) except KeyboardInterrupt: loop.run_until_complete(close()) # cancel all tasks lingering finally: loop.close()
Warning
This function must be the last function to call due to the fact that it is blocking. That means that registration of events or anything being called after this function call will not execute until it returns.
-
activity
¶ The activity being used upon logging in.
- Type:
Optional[
BaseActivity
]
-
allowed_mentions
¶ The allowed mention configuration.
New in version 1.4.
- Type:
Optional[
AllowedMentions
]
-
get_channel
(id)¶ Returns a channel with the given ID.
- Parameters:
id (
int
) – The ID to search for.- Returns:
The returned channel or
None
if not found.- Return type:
Optional[Union[
abc.GuildChannel
,abc.PrivateChannel
]]
-
get_guild
(id)¶ Returns a guild with the given ID.
-
get_user
(id)¶ Returns a user with the given ID.
-
get_emoji
(id)¶ Returns an emoji with the given ID.
-
for ... in
get_all_channels
()¶ A generator that retrieves every
abc.GuildChannel
the client can ‘access’.This is equivalent to:
for guild in client.guilds: for channel in guild.channels: yield channel
Note
Just because you receive a
abc.GuildChannel
does not mean that you can communicate in said channel.abc.GuildChannel.permissions_for()
should be used for that.- Yields:
abc.GuildChannel
– A channel the client can ‘access’.
-
for ... in
get_all_members
()¶ Returns a generator with every
Member
the client can see.This is equivalent to:
for guild in client.guilds: for member in guild.members: yield member
- Yields:
Member
– A member the client can see.
-
await
wait_until_ready
()¶ This function is a coroutine.
Waits until the client’s internal cache is all ready.
-
wait_for
(event, *, check=None, timeout=None)¶ This function is a coroutine.
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The
timeout
parameter is passed ontoasyncio.wait_for()
. By default, it does not timeout. Note that this does propagate theasyncio.TimeoutError
for you in case of timeout and is provided for ease of use.In case the event returns multiple arguments, a
tuple
containing those arguments is returned instead. Please check the documentation for a list of events and their parameters.This function returns the first event that meets the requirements.
Examples
Waiting for a user reply:
@client.event async def on_message(message): if message.content.startswith('$greet'): channel = message.channel await channel.send('Say hello!') def check(m): return m.content == 'hello' and m.channel == channel msg = await client.wait_for('message', check=check) await channel.send('Hello {.author}!'.format(msg))
Waiting for a thumbs up reaction from the message author:
@client.event async def on_message(message): if message.content.startswith('$thumb'): channel = message.channel await channel.send('Send me that 👍 reaction, mate') def check(reaction, user): return user == message.author and str(reaction.emoji) == '👍' try: reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check) except asyncio.TimeoutError: await channel.send('👎') else: await channel.send('👍')
- Parameters:
event (
str
) – The event name, similar to the event reference, but without theon_
prefix, to wait for.check (Optional[Callable[…,
bool
]]) – A predicate to check what to wait for. The arguments must meet the parameters of the event being waited for.timeout (Optional[
float
]) – The number of seconds to wait before timing out and raisingasyncio.TimeoutError
.
- Raises:
asyncio.TimeoutError – If a timeout is provided and it was reached.
- Returns:
Returns no arguments, a single argument, or a
tuple
of multiple arguments that mirrors the parameters passed in the event reference.- Return type:
Any
-
event
(coro)¶ A decorator that registers an event to listen to.
You can find more info about the events on the documentation below.
The events must be a coroutine, if not,
TypeError
is raised.Example
@client.event async def on_ready(): print('Ready!')
- Raises:
TypeError – The coroutine passed is not actually a coroutine.
-
await
change_presence
(*, activity=None, status=None, afk=False)¶ This function is a coroutine.
Changes the client’s presence.
Example
game = discord.Game("with the API") await client.change_presence(status=discord.Status.idle, activity=game)
- Parameters:
activity (Optional[
BaseActivity
]) – The activity being done.None
if no currently active activity is done.status (Optional[
Status
]) – Indicates what status to change to. IfNone
, thenStatus.online
is used.afk (Optional[
bool
]) – Indicates if you are going AFK. This allows the discord client to know how to handle push notifications better for you in case you are actually idle and not lying.
- Raises:
InvalidArgument – If the
activity
parameter is not the proper type.
-
await
fetch_template
(code)¶ This function is a coroutine.
Gets a
Template
from a discord.new URL or code.- Parameters:
code (Union[
Template
,str
]) – The Discord Template Code or URL (must be a discord.new URL).- Raises:
NotFound – The template is invalid.
HTTPException – Getting the template failed.
- Returns:
The template from the URL/code.
- Return type:
-
await
fetch_guild
(guild_id)¶ This function is a coroutine.
Retrieves a
Guild
from an ID.Note
Using this, you will not receive
Guild.channels
,Guild.members
,Member.activity
andMember.voice
perMember
.Note
This method is an API call. For general usage, consider
get_guild()
instead.- Parameters:
guild_id (
int
) – The guild’s ID to fetch from.- Raises:
Forbidden – You do not have access to the guild.
HTTPException – Getting the guild failed.
- Returns:
The guild from the ID.
- Return type:
-
await
create_guild
(name, region=None, icon=None, *, code=None)¶ This function is a coroutine.
Creates a
Guild
.Bot accounts in more than 10 guilds are not allowed to create guilds.
- Parameters:
name (
str
) – The name of the guild.region (
VoiceRegion
) – The region for the voice communication server. Defaults toVoiceRegion.us_west
.icon (
bytes
) – The bytes-like object representing the icon. SeeClientUser.edit()
for more details on what is expected.code (Optional[
str
]) –The code for a template to create the guild with.
New in version 1.4.
- Raises:
HTTPException – Guild creation failed.
InvalidArgument – Invalid icon image format given. Must be PNG or JPG.
- Returns:
The guild created. This is not the same guild that is added to cache.
- Return type:
-
await
fetch_invite
(url, *, with_counts=True)¶ This function is a coroutine.
Gets an
Invite
from a discord.gg URL or ID.Note
If the invite is for a guild you have not joined, the guild and channel attributes of the returned
Invite
will bePartialInviteGuild
andPartialInviteChannel
respectively.- Parameters:
url (Union[
Invite
,str
]) – The Discord invite ID or URL (must be a discord.gg URL).with_counts (
bool
) – Whether to include count information in the invite. This fills theInvite.approximate_member_count
andInvite.approximate_presence_count
fields.
- Raises:
NotFound – The invite has expired or is invalid.
HTTPException – Getting the invite failed.
- Returns:
The invite from the URL/ID.
- Return type:
-
await
delete_invite
(invite)¶ This function is a coroutine.
Revokes an
Invite
, URL, or ID to an invite.You must have the
manage_channels
permission in the associated guild to do this.- Parameters:
- Raises:
Forbidden – You do not have permissions to revoke invites.
NotFound – The invite is invalid or expired.
HTTPException – Revoking the invite failed.
-
await
fetch_widget
(guild_id)¶ This function is a coroutine.
Gets a
Widget
from a guild ID.Note
The guild must have the widget enabled to get this information.
- Parameters:
guild_id (
int
) – The ID of the guild.- Raises:
Forbidden – The widget for this guild is disabled.
HTTPException – Retrieving the widget failed.
- Returns:
The guild’s widget.
- Return type:
-
await
application_info
()¶ This function is a coroutine.
Retrieves the bot’s application information.
- Raises:
HTTPException – Retrieving the information failed somehow.
- Returns:
The bot’s application information.
- Return type:
-
await
fetch_user
(user_id)¶ This function is a coroutine.
Retrieves a
User
based on their ID. This can only be used by bot accounts. You do not have to share any guilds with the user to get this information, however many operations do require that you do.Note
This method is an API call. If you have
Intents.members
and member cache enabled, considerget_user()
instead.- Parameters:
user_id (
int
) – The user’s ID to fetch from.- Raises:
NotFound – A user with this ID does not exist.
HTTPException – Fetching the user failed.
- Returns:
The user you requested.
- Return type:
-
await
fetch_user_profile
(user_id)¶ This function is a coroutine.
Gets an arbitrary user’s profile.
Deprecated since version 1.7.
Note
This can only be used by non-bot accounts.
- Parameters:
user_id (
int
) – The ID of the user to fetch their profile for.- Raises:
Forbidden – Not allowed to fetch profiles.
HTTPException – Fetching the profile failed.
- Returns:
The profile of the user.
- Return type:
-
await
fetch_channel
(channel_id)¶ This function is a coroutine.
Retrieves a
abc.GuildChannel
orabc.PrivateChannel
with the specified ID.Note
This method is an API call. For general usage, consider
get_channel()
instead.New in version 1.2.
- Raises:
InvalidData – An unknown channel type was received from Discord.
HTTPException – Retrieving the channel failed.
NotFound – Invalid Channel ID.
Forbidden – You do not have permission to fetch this channel.
- Returns:
The channel from the ID.
- Return type:
Union[
abc.GuildChannel
,abc.PrivateChannel
]
-
await
fetch_webhook
(webhook_id)¶ This function is a coroutine.
Retrieves a
Webhook
with the specified ID.- Raises:
HTTPException – Retrieving the webhook failed.
NotFound – Invalid webhook ID.
Forbidden – You do not have permission to fetch this webhook.
- Returns:
The webhook you requested.
- Return type:
AutoShardedClient¶
Methods- asyncchange_presence
- asyncclose
- asyncconnect
- defget_shard
- defis_ws_ratelimited
- asyncrequest_offline_members
-
class
discord.
AutoShardedClient
(*args, loop=None, **kwargs)¶ A client similar to
Client
except it handles the complications of sharding for the user into a more manageable and transparent single process bot.When using this client, you will be able to use it as-if it was a regular
Client
with a single shard when implementation wise internally it is split up into multiple shards. This allows you to not have to deal with IPC or other complicated infrastructure.It is recommended to use this client only if you have surpassed at least 1000 guilds.
If no
shard_count
is provided, then the library will use the Bot Gateway endpoint call to figure out how many shards to use.If a
shard_ids
parameter is given, then those shard IDs will be used to launch the internal shards. Note thatshard_count
must be provided if this is used. By default, when omitted, the client will launch shards from 0 toshard_count - 1
.-
latency
¶ Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds.
This operates similarly to
Client.latency()
except it uses the average latency of every shard’s latency. To get a list of shard latency, check thelatencies
property. Returnsnan
if there are no shards ready.- Type:
-
latencies
¶ A list of latencies between a HEARTBEAT and a HEARTBEAT_ACK in seconds.
This returns a list of tuples with elements
(shard_id, latency)
.
-
get_shard
(shard_id)¶ Optional[
ShardInfo
]: Gets the shard information at a given shard ID orNone
if not found.
-
shards
¶ Returns a mapping of shard IDs to their respective info object.
- Type:
Mapping[int,
ShardInfo
]
-
await
request_offline_members
(*guilds)¶ This function is a coroutine.
Requests previously offline members from the guild to be filled up into the
Guild.members
cache. This function is usually not called. It should only be used if you have thefetch_offline_members
parameter set toFalse
.When the client logs on and connects to the websocket, Discord does not provide the library with offline members if the number of members in the guild is larger than 250. You can check if a guild is large if
Guild.large
isTrue
.Warning
This method is deprecated. Use
Guild.chunk()
instead.- Parameters:
*guilds (
Guild
) – An argument list of guilds to request offline members for.- Raises:
InvalidArgument – If any guild is unavailable in the collection.
-
await
connect
(*, reconnect=True)¶ This function is a coroutine.
Creates a websocket connection and lets the websocket listen to messages from Discord. This is a loop that runs the entire event system and miscellaneous aspects of the library. Control is not resumed until the WebSocket connection is terminated.
- Parameters:
reconnect (
bool
) – If we should attempt reconnecting, either due to internet failure or a specific failure on Discord’s part. Certain disconnects that lead to bad state will not be handled (such as invalid sharding payloads or bad tokens).- Raises:
GatewayNotFound – If the gateway to connect to Discord is not found. Usually if this is thrown then there is a Discord API outage.
ConnectionClosed – The websocket connection has been terminated.
-
await
change_presence
(*, activity=None, status=None, afk=False, shard_id=None)¶ This function is a coroutine.
Changes the client’s presence.
Example:
game = discord.Game("with the API") await client.change_presence(status=discord.Status.idle, activity=game)
- Parameters:
activity (Optional[
BaseActivity
]) – The activity being done.None
if no currently active activity is done.status (Optional[
Status
]) – Indicates what status to change to. IfNone
, thenStatus.online
is used.afk (
bool
) – Indicates if you are going AFK. This allows the discord client to know how to handle push notifications better for you in case you are actually idle and not lying.shard_id (Optional[
int
]) – The shard_id to change the presence to. If not specified orNone
, then it will change the presence of every shard the bot can see.
- Raises:
InvalidArgument – If the
activity
parameter is not of proper type.
-
is_ws_ratelimited
()¶ bool
: Whether the websocket is currently rate limited.This can be useful to know when deciding whether you should query members using HTTP or via the gateway.
This implementation checks if any of the shards are rate limited. For more granular control, consider
ShardInfo.is_ws_ratelimited()
.New in version 1.6.
Application Info¶
AppInfo¶
AttributesMethods-
class
discord.
AppInfo
¶ Represents the application info for the bot provided by Discord.
-
bot_public
¶ Whether the bot can be invited by anyone or if it is locked to the application owner.
- Type:
-
bot_require_code_grant
¶ Whether the bot requires the completion of the full oauth2 code grant flow to join.
- Type:
-
summary
¶ If this application is a game sold on Discord, this field will be the summary field for the store page of its primary SKU.
New in version 1.3.
- Type:
-
verify_key
¶ The hex encoded key for verification in interactions and the GameSDK’s GetTicket.
New in version 1.3.
- Type:
-
guild_id
¶ If this application is a game sold on Discord, this field will be the guild to which it has been linked to.
New in version 1.3.
- Type:
Optional[
int
]
-
primary_sku_id
¶ If this application is a game sold on Discord, this field will be the id of the “Game SKU” that is created, if it exists.
New in version 1.3.
- Type:
Optional[
int
]
-
slug
¶ If this application is a game sold on Discord, this field will be the URL slug that links to the store page.
New in version 1.3.
- Type:
Optional[
str
]
-
cover_image
¶ If this application is a game sold on Discord, this field will be the hash of the image on store embeds
New in version 1.3.
- Type:
Optional[
str
]
-
icon_url
¶ Retrieves the application’s icon asset.
This is equivalent to calling
icon_url_as()
with the default parameters (‘webp’ format and a size of 1024).New in version 1.3.
- Type:
-
icon_url_as
(*, format='webp', size=1024)¶ Returns an
Asset
for the icon the application has.The format must be one of ‘webp’, ‘jpeg’, ‘jpg’ or ‘png’. The size must be a power of 2 between 16 and 4096.
New in version 1.6.
- Parameters:
- Raises:
InvalidArgument – Bad image format passed to
format
or invalidsize
.- Returns:
The resulting CDN asset.
- Return type:
-
cover_image_url
¶ Retrieves the cover image on a store embed.
This is equivalent to calling
cover_image_url_as()
with the default parameters (‘webp’ format and a size of 1024).New in version 1.3.
- Type:
-
cover_image_url_as
(*, format='webp', size=1024)¶ Returns an
Asset
for the image on store embeds if this application is a game sold on Discord.The format must be one of ‘webp’, ‘jpeg’, ‘jpg’ or ‘png’. The size must be a power of 2 between 16 and 4096.
New in version 1.6.
- Parameters:
- Raises:
InvalidArgument – Bad image format passed to
format
or invalidsize
.- Returns:
The resulting CDN asset.
- Return type:
-
Team¶
-
class
discord.
Team
¶ Represents an application team for a bot provided by Discord.
-
members
¶ A list of the members in the team
New in version 1.3.
- Type:
List[
TeamMember
]
-
icon_url
¶ Retrieves the team’s icon asset.
This is equivalent to calling
icon_url_as()
with the default parameters (‘webp’ format and a size of 1024).- Type:
-
icon_url_as
(*, format='webp', size=1024)¶ Returns an
Asset
for the icon the team has.The format must be one of ‘webp’, ‘jpeg’, ‘jpg’ or ‘png’. The size must be a power of 2 between 16 and 4096.
New in version 2.0.
- Parameters:
- Raises:
InvalidArgument – Bad image format passed to
format
or invalidsize
.- Returns:
The resulting CDN asset.
- Return type:
-
owner
¶ The team’s owner.
- Type:
Optional[
TeamMember
]
-
TeamMember¶
Attributes-
class
discord.
TeamMember
¶ Represents a team member in a team.
-
x == y
Checks if two team members are equal.
-
x != y
Checks if two team members are not equal.
-
hash(x)
Return the team member’s hash.
-
str(x)
Returns the team member’s name with discriminator.
New in version 1.3.
-
discriminator
¶ The team member’s discriminator. This is given when the username has conflicts.
- Type:
-
membership_state
¶ The membership state of the member (e.g. invited or accepted)
- Type:
-
-
-
-
await