Welcome to discord.aio’s documentation!¶
See the reference documentation.
discord.aio¶
discord.aio is an asynchronous Discord API wrapper
Currently under very early development
Python 3.6+ only.
Documentation¶
You can find the module documentation here: documentation
Installation¶
With pip:¶
pip3 install discord.aio
From source:¶
git clone https://github.com/Ryozuki/discord.aio && cd discord.aio && pip3 install .
Local development¶
git clone https://github.com/Ryozuki/discord.aio
cd discord.aio && pip3 install -e .
Example bot¶
import asyncio
import os
import logging
from discordaio import DiscordBot
logging.basicConfig(
level='DEBUG', format='%(asctime)s - %(name)s - %(levelname)s: %(message)s')
logger = logging.getLogger('my_lovely_bot')
if __name__ == '__main__':
TOKEN = os.environ['DISCORD_TOKEN']
bot = DiscordBot(TOKEN)
@bot.event()
async def on_ready():
logger.info('Connected!')
logger.info(f'My username is {bot.user}')
@bot.event('on_message') # You can also use a custom function name.
async def foo_bar(message):
logger.info(f'{message.author}: {message.content}')
bot.run()
Here you can find a more extensive example.
TODO¶
- Add compression support
- Add bot shards support
- Handle ISO8601 timestamp
- Make the DiscordBot methods better.
Your first bot¶
TODO: Do this
Events¶
Events¶
Event: on_ready¶
Raised when:
- The client is ready and connected.
Note: Before this event is raised, DiscordBot.user is filled with information.
@bot.event()
async def on_ready():
print('Connected!')
print(f'My username is {bot.user}')
Event: on_resumed¶
Raised when:
- A client has sent a resume payload to the gateway (for resuming existing sessions).
Event: on_invalid_session¶
Raised when:
- The gateway could not initialize a session after receiving an Opcode 2 Identify
- The gateway could not resume a previous session after receiving an Opcode 6 Resume
- The gateway has invalidated an active session and is requesting client action
Event Parameters:
resume
(bool): Indicates whether the client can resume.
Event: on_channel_create¶
Raised when:
- A new channel is created
Event Parameters:
channel
(Channel): The created channel
Event: on_channel_update¶
Raised when:
- A channel is updated
Event Parameters:
channel
(Channel): The updated channel
Event: on_channel_delete¶
Raised when:
- A channel is deleted
Event Parameters:
channel
(Channel): The deleted channel
Event: on_channel_pin¶
Raised when:
- A message is pinned or unpinned in a text channel.
Note: This is not raised when a pinned message is deleted.
Event Parameters:
channel_id
(int): The id of the channellast_pin_timestamp
(int): The time at which the most recent pinned message was pinned
Event: on_guild_create¶
Raised when:
- After the
on_ready
event, to fullfill the guild information. - When a Guild becomes available again to the client.
- When the current user joins a new Guild.
Event Parameters:
guild
(Guild): The guild
@bot.event()
async def on_guild_create(guild):
print(f'I\'m connected to {guild.name} guild, it got {len(guild.channels)} channels.')
Event: on_guild_delete¶
Raised when:
- A guild becomes unavailable during a guild outage
- The user leaves or is removed from a guild
- When the current user joins a new Guild.
Note: If the unavailable attribute is not set, the user was removed from the guild.
Event Parameters:
guild
(Guild): The guild
@bot.event()
async def on_guild_delete(guild):
print(f'{guild.name} went offline?')
if not guild.unavailable:
print(f'I got removed from {guild}!')
Event: on_guild_emojis_update¶
Raised when:
- When a guild’s emojis have been updated.
Event Parameters:
guild_id
(int): The guild idemojis
(list): A list of emojis
Event: on_guild_integrations_update¶
Raised when:
- When a guild integration is updated.
Event Parameters:
guild_id
(int): The guild id.
Event: on_guild_member_add¶
Raised when:
- When a new user joins a guild.
Event Parameters:
guild_id
(int): The guild id.member
(GuildMember): The user that joined.
Event: on_guild_member_remove¶
Raised when:
- A user is removed from a guild (leave/kick/ban).
Event Parameters:
guild_id
(int): The guild id.user
(User): The user that was removed/left.
Event: on_guild_member_update¶
Raised when:
- A guild member is updated
Event Parameters:
guild_id
(int): The guild id.roles
(list): User role ids.user
(User): The user.nick
(str): Nickname of the user in the guild.
Event: on_guild_members_chunk¶
Raised when:
- In response to Guild Request Members.
Event Parameters:
guild_id
(int): The guild id.members
(list): Set of guild members
Event: on_guild_role_create¶
Raised when:
- A guild role is created.
Event Parameters:
guild_id
(int): The guild id.role
(Role): The role created
Event: on_guild_role_update¶
Raised when:
- A guild role is updated.
Event Parameters:
guild_id
(int): The guild id.role
(Role): The role updated
Event: on_guild_role_delete¶
Raised when:
- A guild role is deleted.
Event Parameters:
guild_id
(int): The guild id.role_id
(int): The id of the deleted role
Event: on_ban¶
Raised when:
- A user is banned from a guild
Event Parameters:
guild_id
(int): The guild id.user
(User): The banned .
Event: on_ban_remove¶
Raised when:
- A user is unbanned from a guild
Event Parameters:
guild_id
(int): The guild id.user
(User): The unbanned user.
Event: on_message¶
Raised when:
- A user send a message to a channel
Event Parameters:
user_id
(int): The id of the user that started typing.channel_id
(int): The id of the channel where the action happened.timestamp
(int): The timestamp telling when it happened.
@bot.event()
async def on_message(message):
print(f'{message.author}: {message.content}')
Event: on_message_update¶
Raised when:
- A message is updated.
Note: Unlike creates, message updates may contain only a subset of the full message object payload (but will always contain an id and channel_id)
Event Parameters:
message
(ChannelMessage): The Channel message that has been updated
@bot.event()
async def on_message_create(message):
print(f'A message with id {message.id} has been updated.')
Event: on_message_delete¶
Raised when:
- A message is deleted.
Event Parameters:
id
(int): The id of the message.channel_id
(int): The id of the channel.
@bot.event()
async def on_message_delete(id, channel_id):
print(f'A message with id {id} has been deleted.')
Event: on_message_delete_bulk¶
Raised when:
- Multiple messages are deleted at once.
Event Parameters:
ids
(int): The ids of the messageschannel_id
(int): The id of the channel
@bot.event()
async def on_message_delete_bulk(ids, channel_id):
print(f'Multiple messages have been deleted')
Event: on_message_reaction_add¶
Raised when:
- A user adds a reaction to a message
Event Parameters:
user_id
(int): The id of the userchannel_id
(int): The id of the channelmessage_id
(int): The id of the messageemoji
(Emoji): The emoji used to react
@bot.event()
async def on_message_reaction_add(user_id, channel_id, message_id, emoji):
user = await bot.get_user(user_id)
print(f'{user} reacted to a message with {emoji.name}')
Event: on_message_reaction_remove¶
Raised when:
- A user removes a reaction from a message
Event Parameters:
user_id
(int): The id of the userchannel_id
(int): The id of the channelmessage_id
(int): The id of the messageemoji
(Emoji): The emoji used to react
@bot.event()
async def on_message_reaction_add(user_id, channel_id, message_id, emoji):
user = await bot.get_user(user_id)
print(f'{user} removed reaction {emoji.name} from a message.')
Event: on_message_reaction_remove_all¶
Raised when:
- A user explicitly removes all reactions from a message.
Event Parameters:
channel_id
(int): The id of the channelmessage_id
(int): The id of the message
Event: on_presence_update¶
Raised when:
- A user’s presence is updated for a guild.
Note: The user object within this event can be partial, the only field which must be set is the id field
Event Parameters:
user
(User): The user presence is being updated forroles
(list): Ids of the roles this user is ingame
(?Activity): Null, or the user’s current activityguild_id
(int): The guild idstatus
(str): Either “idle”, “dnd”, “online”, or “offline”
Event: on_typing_start¶
Raised when:
- A user starts typing in a channel
Event Parameters:
user_id
(int): The id of the user that started typing.channel_id
(int): The id of the channel where the action happened.timestamp
(int): The timestamp telling when it happened.
@bot.event()
async def on_typing_start(user_id, channel_id, timestamp):
user = await bot.get_user(user_id)
print(f'{user} started typing!')
Event: on_user_update¶
Raised when:
- Properties about the user change
Event Parameters:
user
(User): The user that has been updated
Event: on_voice_state_update¶
Raised when:
- Someone joins/leaves/moves voice channels.
Event Parameters:
voice_state
(VoiceState): The voice state object
Event: on_voice_server_update¶
Raised when:
- A guild’s voice server is updated.
- This is sent when initially connecting to voice, and when the current voice instance fails over to a new server.
Event Parameters:
token
(str): Voice connection token-guild_id
(int): The guild this voice server update is forendpoint
(str): The voice server host
Event: on_webhooks_update¶
Raised when:
- A guild’s voice server is updated.
- This is sent when initially connecting to voice, and when the current voice instance fails over to a new server.
Event Parameters:
guild_id
(int): Id of the guildchannel_id
(int): Id of the channel
discordaio
¶
discord.aio is an asynchronous Discord API wrapper for python 3.6+
Submodules¶
discordaio.activity
¶
Classes¶
Activity
: Represents a discord activityActivityParty
: Activity partyActivityTimestamps
: Activity timestampsActivityAssets
: Activity assets
-
class
discordaio.activity.
Activity
(name='', type=0, url='', timestamps=None, application_id=0, details='', state='', party=None, assets=None)[source]¶ Represents a discord activity
New in version 0.2.0.
-
timestamps
¶ object unix timestamps for start and/or end of the game
Type: Timestamps
-
party
¶ object information for the current party of the player
Type: Party
-
assets
¶ object images for the presence and their hover texts
Type: Assets
Inheritance
-
-
class
discordaio.activity.
ActivityParty
(id='', size=[])[source]¶ Activity party
New in version 0.2.0.
-
size
¶ array of two integers (current_size, max_size), used to show the party’s current and maximum size
Type: list
ofint
Inheritance
-
-
class
discordaio.activity.
ActivityTimestamps
(start=0, end=0)[source]¶ Activity timestamps
New in version 0.2.0.
Inheritance
discordaio.base
¶
discordaio.channel
¶
Contains all related Channel Discord objects
Classes¶
Channel
: Represents a guild or DM channel within Discord.ChannelMessage
: Represents a message sent in a channel within Discord.Overwrite
: Represents a Overwrite object.MessageActivity
: Represents a Message Activity.MessageApplication
: Represents a Message Application.Reaction
: Represents a Reaction.Embed
: Represents a discord EmbedEmbedThumbnail
: Represents a embed thumbnail objectEmbedVideo
: Represents a embed videoEmbedImage
: Represents a embed imageEmbedProvider
: Represents a embed providerEmbedAuthor
: Represents a embed authorEmbedFooter
: Represents a embed footerEmbedField
: Represents a embed fieldAttachment
: Represents a attachment
-
class
discordaio.channel.
Channel
(id: int = None, type: int = 0, guild_id: int = None, position: int = None, permission_overwrites: List[discordaio.channel.Overwrite] = [], name: str = None, topic: str = None, nsfw: bool = False, last_message_id: int = None, bitrate: int = None, user_limit: int = None, recipients: List[discordaio.user.User] = [], icon: str = None, owner_id: int = None, application_id: int = None, parent_id: int = None, last_pin_timestamp: int = None)[source]¶ Represents a guild or DM channel within Discord.
New in version 0.2.0.
-
id
¶ the id of this channel
-
type
¶ the value_type of channel
-
guild_id
¶ the id of the guild
-
position
¶ sorting position of the channel
-
permission_overwrites
¶ explicit permission overwrites for members and roles
-
name
¶ the name of the channel (2-100 characters)
-
topic the channel topic
Type: 0-1024 characters
-
nsfw
¶ if the channel is nsfw
-
last_message_id
¶ the id of the last message sent in this channel (may not point to an existing or valid message)
-
bitrate
¶ the bitrate (in bits) of the voice channel
-
user_limit
¶ the user limit of the voice channel
-
recipients
¶ the recipients of the DM
-
icon
¶ icon hash
-
owner_id
¶ id of the DM creator
-
application_id application id of the group DM creator if it is bot-created
-
parent_id
¶ id of the parent category for a channel
-
last_pin_timestamp
¶ timestamp when the last pinned message was pinned
Inheritance
-
await
bulk_delete_messages
(ids: List[T])[source]¶ Delete multiple messages in a single request. This endpoint can only be used on guild channels and requires the MANAGE_MESSAGES permission.
This endpoint will not delete messages older than 2 weeks, and will fail if any message provided is older than that.
New in version 0.3.0.
-
await
create_invite
(max_age: int, max_uses=0, temporary=False, unique=False) → discordaio.invite.Invite[source]¶ Create a new invite object for the channel. Only usable for guild channels. Requires the CREATE_INSTANT_INVITE permission.
New in version 0.3.0.
-
await
delete_permission
(overwrite_id)[source]¶ Delete a channel permission overwrite for a user or role in a channel. Only usable for guild channels. Requires the MANAGE_ROLES permission.
New in version 0.3.0.
-
await
delete_pinned_message
(message_id)[source]¶ Delete a pinned message. Requires the MANAGE_MESSAGES permission.
New in version 0.3.0.
-
await
get_invites
() → List[discordaio.invite.Invite][source]¶ Returns a list of invite objects (with invite metadata) for the channel. Only usable for guild channels. Requires the MANAGE_CHANNELS permission.
New in version 0.3.0.
-
await
get_message
(message_id) → discordaio.channel.ChannelMessage[source]¶ Gets a specific channel message.
-
await
get_messages
(limit: int = None, around: int = None, before: int = None, after: int = None) → List[discordaio.channel.ChannelMessage][source]¶ Gets channel messages
New in version 0.3.0.
-
await
get_pinned_messages
() → List[discordaio.channel.ChannelMessage][source]¶ Returns all pinned messages in the channel as an array of message objects.
New in version 0.3.0.
-
await
pin_message
(message_id)[source]¶ Pin a message in a channel. Requires the MANAGE_MESSAGES permission.
New in version 0.3.0.
-
await
refresh
() → discordaio.channel.Channel[source]¶ Returns a “refreshed” channel instance, may be used to make sure you have the latest state of the channel.
New in version 0.3.0.
Example
channel = await channel.refresh()
Returns: The requested channel.
-
-
class
discordaio.channel.
ChannelMessage
(id=None, channel_id=None, author: discordaio.user.User = None, content: str = None, timestamp: int = None, edited_timestamp: int = None, tts: bool = False, mention_everyone: bool = False, mentions: List[discordaio.user.User] = [], mention_roles: List[discordaio.role.Role] = [], attachments: List[discordaio.channel.Attachment] = [], embeds: List[discordaio.channel.Embed] = [], reactions: List[discordaio.channel.Reaction] = [], nonce: int = None, pinned=False, webhook_id=None, type=None, activity=<discordaio.channel.MessageActivity object>, application=<discordaio.channel.MessageApplication object>)[source]¶ Represents a message sent in a channel within Discord.
New in version 0.2.0.
Note
The author object follows the structure of the
User
object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by aWebhook
, the author object corresponds to the webhook’s id, username, and avatar. You can tell if a message is generated by a webhook by checking for the webhook_id on the message object.-
id
¶ id of the message
-
channel_id
¶ id of the channel the message was sent in
the author of this message (not guaranteed to be a valid user, see below)
-
content
¶ contents of the message
-
timestamp
¶ timestamp when this message was sent
-
edited_timestamp
¶ timestamp when this message was edited (or null if never)
-
tts
¶ whether this was a TTS message
-
mention_everyone
¶ whether this message mentions everyone
-
mentions
¶ objects users specifically mentioned in the message
-
mention_roles
¶ object ids roles specifically mentioned in this message
-
attachments
¶ objects any attached files
-
embeds
¶ objects any embedded content
-
reactions
¶ objects reactions to the message
-
nonce
¶ used for validating a message was sent
-
pinned whether this message is pinned
-
webhook_id
¶ if the message is generated by a webhook, this is the webhook’s id
-
type
¶ type of message
-
activity
¶ activity object sent with Rich Presence-related chat embeds
-
application
¶ application object sent with Rich Presence-related chat embeds
Inheritance
-
await
delete
()[source]¶ Delete a message. If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the MANAGE_MESSAGES permission
-
await
delete_all_reactions
()[source]¶ Deletes all reactions on a message. This endpoint requires the ‘MANAGE_MESSAGES’ permission to be present on the current user.
-
await
delete_user_reaction
(user_id, emoji_id)[source]¶ Deletes another user’s reaction. This endpoint requires the ‘MANAGE_MESSAGES’ permission to be present on the current user.
-
-
class
discordaio.channel.
Overwrite
(id=None, type=None, allow=None, deny=None)[source]¶ Represents a Overwrite object.
New in version 0.2.0.
Inheritance
-
class
discordaio.channel.
MessageActivity
(type: int = None, party_id: int = None)[source]¶ Represents a Message Activity.
New in version 0.2.0.
-
type
¶ type of message activity
-
party_id
¶ party_id from a Rich Presence event
Inheritance
-
-
class
discordaio.channel.
MessageApplication
(id=None, cover_image=None, description=None, icon=None, name=None)[source]¶ Represents a Message Application.
New in version 0.2.0.
Inheritance
-
class
discordaio.channel.
Reaction
(count: int = None, me: bool = False, emoji: discordaio.emoji.Emoji = None)[source]¶ Represents a Reaction.
New in version 0.2.0.
-
count
¶ times this emoji has been used to react
-
me
¶ whether the current user reacted using this emoji
-
emoji emoji information
Inheritance
-
-
class
discordaio.channel.
Embed
(title=None, type=None, description=None, url=None, timestamp=None, color=None, footer=<discordaio.channel.EmbedFooter object>, image=<discordaio.channel.EmbedImage object>, thumbnail=<discordaio.channel.EmbedThumbnail object>, video=<discordaio.channel.EmbedVideo object>, provider=<discordaio.channel.EmbedProvider object>, author=<discordaio.channel.EmbedAuthor object>, fields=[])[source]¶ Represents a discord Embed
New in version 0.2.0.
footer information
Type: EmbedFooter
-
image
¶ image information
Type: EmbedImage
-
thumbnail
¶ thumbnail information
Type: EmbedThumbnail
-
video
¶ video information
Type: EmbedVideo
-
provider
¶ provider information
Type: EmbedProvider
author information
Type: EmbedAuthor
-
fields
¶ fields information
Type: list
ofEmbedField
Inheritance
-
class
discordaio.channel.
EmbedThumbnail
(url=None, proxy_url=None, height=None, width=None)[source]¶ Represents a embed thumbnail object
New in version 0.2.0.
Inheritance
-
class
discordaio.channel.
EmbedVideo
(url=None, height=None, width=None)[source]¶ Represents a embed video
New in version 0.2.0.
Inheritance
-
class
discordaio.channel.
EmbedImage
(url=None, proxy_url=None, height=None, width=None)[source]¶ Represents a embed image
New in version 0.2.0.
Inheritance
-
class
discordaio.channel.
EmbedProvider
(name=None, url=None)[source]¶ Represents a embed provider
New in version 0.2.0.
Inheritance
-
class
discordaio.channel.
EmbedAuthor
(name=None, url=None, icon_url=None, proxy_icon_url=None)[source]¶ Represents a embed author
New in version 0.2.0.
Inheritance
Represents a embed footer
New in version 0.2.0.
footer text
Type: str
url of footer icon (only supports http(s) and attachments)
Type: str
a proxied url of footer icon
Type: str
Inheritance
-
class
discordaio.channel.
EmbedField
(name=None, value=None, inline=False)[source]¶ Represents a embed field
New in version 0.2.0.
Inheritance
discordaio.client
¶
Classes¶
DiscordBot
: This class represents a discord bot object, it has many utility methods for making a bot.
-
class
discordaio.client.
DiscordBot
(token: str)[source]¶ This class represents a discord bot object, it has many utility methods for making a bot.
New in version 0.2.0.
-
http
¶ Used for making http requests and websocket creation.
Type: HTTPHandler
-
ws
¶ The websocket used for communication
Type: DiscordWebsocket
Inheritance
-
event
(name: str = None)[source]¶ DiscordBot event decorator, uses the function’s name or the ‘name’ parameter to subscribe to a event
New in version 0.2.0.
-
await
get_channel
(channel_id: int) → discordaio.channel.Channel[source]¶ Gets a channel from it’s id
New in version 0.2.0.
Parameters: channel_id – The channel id
-
await
get_dms
() → List[discordaio.channel.Channel][source]¶ Gets a list of dms.
New in version 0.2.0.
Returns: The DMs channels Return type: list
ofChannel
-
await
get_guild
(guild_id: int) → discordaio.guild.Guild[source]¶ Returns a Guild object from a guild id.
New in version 0.2.0.
Parameters: guild_id ( int
) – The guild idReturns: The requested guild Return type: Guild
-
await
get_guilds
() → List[discordaio.guild.Guild][source]¶ Returns a list of guilds where the bot is in.
New in version 0.2.0.
-
await
get_self_user
() → discordaio.user.User[source]¶ Returns the bot user object. (it’s like get_user(‘@me’))
New in version 0.2.0.
-
await
get_user
(id) → discordaio.user.User[source]¶ Gets the user object from the given user id.
New in version 0.2.0.
Parameters: id ( int
) – The user idReturns: The requested user Return type: User
-
await
move_channels
(guild_id: int, array: List[Tuple[int, int]])[source]¶ Modify the positions of a set of channel objects for the guild.
Note
Requires ‘MANAGE_CHANNELS’ permission. Fires multiple Channel Update events. Only channels to be modified are required, with the minimum being a swap between at least two channels.
Parameters: - guild_id – The id of the guild.
- array – A list of tuples containing (channel_id, position)
-
discordaio.constants
¶
Variables¶
-
discordaio.constants.
DISCORD_CDN
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’. .. code-block:: text
-
discordaio.constants.
DISCORD_API_URL
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’. .. code-block:: text
discordaio.emoji
¶
discordaio.enums
¶
Classes¶
MessageNotificationLevel
: An enumeration.ExplicitContentFilterLevel
: An enumeration.MFALevel
: An enumeration.VerificationLevel
: An enumeration.ChannelTypes
: An enumeration.MessageActivityTypes
: An enumeration.GatewayOpcodes
: An enumeration.
discordaio.exceptions
¶
Exceptions¶
WebSocketCreationError
: Common base class for all non-exit exceptions.EventTypeError
: Common base class for all non-exit exceptions.AuthorizationError
: Common base class for all non-exit exceptions.UnhandledEndpointStatusError
: Common base class for all non-exit exceptions.
discordaio.guild
¶
Classes¶
Guild
: Represents a guildGuildMember
: Represents a guild memberGuildEmbed
: Represents a guild embedIntegrationAccount
: Represents a integration accountIntegration
: Represents a integrationBan
: Represents a ban
-
class
discordaio.guild.
Guild
(id=0, name='', icon='', splash='', owner=False, owner_id=0, permissions=0, region='', afk_channel_id=0, afk_timeout=0, embed_enabled=False, embed_channel_id=0, verification_level=0, default_message_notifications=0, explicit_content_filter=0, roles=[], emojis=[], features=[], mfa_level=0, application_id=0, widget_enabled=False, widget_channel_id=0, system_channel_id=0, joined_at=None, large=None, unavailable=None, member_count=None, voice_states=None, members=[], channels=None, presences=None)[source]¶ Represents a guild
New in version 0.2.0.
Note
Guilds in Discord represent an isolated collection of users and channels, and are often referred to as “servers” in the UI.
-
permissions
¶ total permissions for the user in the guild (does not include channel overrides)
Type: int
, optional
is this guild unavailable
Type: bool
, optional
Inheritance
-
await
create_channel
(channel: discordaio.channel.Channel) → discordaio.channel.Channel[source]¶ Creates a new guild channel
New in version 0.3.0.
Parameters: channel – The channel to create.
-
await
delete
() → None[source]¶ Deletes the guild
New in version 0.3.0.
Raises: AuthorizationError
– Raised if you have no authorization to delete the guild.
-
await
get_channels
() → discordaio.channel.Channel[source]¶ Returns a list of channels withing the guild.
New in version 0.3.0.
-
get_icon
() → str[source]¶ Returns the guild icon
New in version 0.2.0.
Returns: The icon link Return type: str
-
await
get_member
(member_id: int) → discordaio.guild.GuildMember[source]¶ Gets a guild member.
New in version 0.3.0.
Parameters: member_id – The member id
-
get_splash
()[source]¶ Returns the guild splash
New in version 0.2.0.
Returns: The splash link Return type: str
-
is_owner
(member: discordaio.guild.GuildMember) → bool[source]¶ Returns wether the guild member is the owner of the guild
New in version 0.2.0.
Parameters: member ( GuildMember
) – The memberReturns: True if it’s the owner, False otherwise. Return type: bool
-
-
class
discordaio.guild.
GuildMember
(user=<User Object: #, 0>, nick='', roles=[], joined_at=None, deaf=False, mute=False)[source]¶ Represents a guild member
New in version 0.2.0.
Inheritance
-
class
discordaio.guild.
GuildEmbed
(enabled=False, channel_id=0)[source]¶ Represents a guild embed
New in version 0.2.0.
Inheritance
-
class
discordaio.guild.
IntegrationAccount
(id='', name='')[source]¶ Represents a integration account
New in version 0.2.0.
Inheritance
discordaio.http
¶
discordaio.invite
¶
Classes¶
Invite
: Represents a code that when used, adds a user to a guild.
-
class
discordaio.invite.
Invite
(code='', guild: Optional[discordaio.guild.Guild] = None, channel: Optional[discordaio.channel.Channel] = None, inviter: Optional[discordaio.user.User] = None, uses=0, max_uses=0, max_age=0, temporary=False, created_at=None, revoked=False)[source]¶ Represents a code that when used, adds a user to a guild.
New in version 0.2.0.
Inheritance
discordaio.permissions
¶
TODO: do this, remember to do: channel edit permissions endpoint https://discordapp.com/developers/docs/topics/permissions#permissions
discordaio.role
¶
discordaio.user
¶
Users in Discord are generally considered the base entity. Users can spawn across the entire platform, be members of guilds, participate in text and voice chat, and much more. Users are separated by a distinction of “bot” vs “normal.” Although they are similar, bot users are automated users that are “owned” by another user. Unlike normal users, bot users do not have a limitation on the number of Guilds they can be a part of.
Classes¶
User
: Represents a discord userUserConnection
: Represents a discord user connection
-
class
discordaio.user.
User
(id=0, username='', discriminator='', avatar='', bot=False, system=False, mfa_enabled=False, locale='', verified=False, email='', flags=0, premium_type=0, public_flags=0)[source]¶ Represents a discord user
New in version 0.2.0.
-
system
¶ whether the user is an Official Discord System user (part of the urgent message system)
Type: bool
, optional
the type of Nitro subscription on a user’s account
Type: int
, optional
Inheritance
-
discordaio.version
¶
Variables¶
-
discordaio.version.
__version__
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’. .. code-block:: text
‘0.3.1’
discordaio.voice
¶
Classes¶
VoiceState
: Used to represent a user’s voice connection status.VoiceRegion
: Attributes:
-
class
discordaio.voice.
VoiceState
(guild_id: Optional[int] = None, channel_id: int = 0, user_id: int = 0, session_id: str = '', deaf=False, mute=False, self_deaf=False, self_mute=False, suppress=False)[source]¶ Used to represent a user’s voice connection status.
Inheritance
discordaio.webhook
¶
Webhooks are a low-effort way to post messages to channels in Discord. They do not require a bot user or authentication to use.
Classes¶
Webhook
: Used to represent a webhook.
discordaio.websocket
¶
Classes¶
DiscordWebsocket
: Class used for handling the websocket connection with the discord gateway
-
class
discordaio.websocket.
DiscordWebsocket
(http: discordaio.http.HTTPHandler = None, session_id: str = None, shards: list = [])[source]¶ Class used for handling the websocket connection with the discord gateway
New in version 0.2.0.
-
http
¶ Used for sending http requests and session handling.
Type: HTTPHandler
-
ws (
class:aiohttp.ClientWebSocketResponse``): The websocket
Inheritance
-
Changelog¶
Version 0.4.0 (dev)¶
- Updated to discord api v8
Version 0.3.1¶
- Fixed async error when closing bot using ctrl-c
- Added Channel#send_message
- Added Channel#mention
- Added Channel#typing
- Added Channel#delete
- Added Channel#update
- Added Channel#refresh
- Added Channel#get_message
- Added ChannelMessage#delete_own_reaction
- Added ChannelMessage#delete_user_reaction
- Added ChannelMessage#delete_all_reactions
- Added ChannelMessage#get_reactions
- Added ChannelMessage#update
- Added ChannelMessage#delete
- Added ChannelMessage#bulk_delete_messages
- Added ChannelMessage#get_invites
- Added ChannelMessage#create_invite
- Added ChannelMessage#delete_permission
- Added ChannelMessage#get_pinned_messages
- Added ChannelMessage#pin_message
- Added ChannelMessage#delete_pinned_message
- Moved DiscordBot#get_messages to Channel#get_messages
- Moved DiscordBot#leave_guild to Guild#leave
- Moved DiscordBot#get_guild_member to Guild#get_member
- Moved DiscordBot#get_guild_members to Guild#get_members
- Moved DiscordBot#create_guild_channel to Guild#create_channel
- Moved DiscordBot#delete_guild to Guild#delete
- Moved DiscordBot#get_guild_channels to Guild#get_channels
- Moved DiscordBot#modify_channel to Channel#update
Version 0.2.2¶
- Added DiscordBot.get_guild_channels method
- Added DiscordBot.create_guild_channel method
- Added DiscordBot.delete_guild method
- Added DiscordBot.move_channels method
- Added NotFoundError exception
- Added GatewayUnavailable exception
- Added BadRequestError exception
- Added AuthorizationError exception
- Fixed a bug in websocket
Version 0.2.0¶
- All discord events can be used now.
Version 0.1.0¶
- Initial development version