Adapt.py API Reference#

Client and Events#

Client#

class adapt.Client(*, loop=None, session=None, server=('https://api.adapt.chat', 'wss://harmony.adapt.chat', 'https://convey.adapt.chat'), token=None, status=Status.online)#

Represents a client that interacts with Adapt.

This class inherits from EventDispatcher. See the documentation for that class for documentation on event listeners.

loop#

The asyncio event loop the client uses.

Type:

asyncio.AbstractEventLoop

http#

The HTTP client utilized by this client that interacts with Adapt HTTP requests.

Type:

HTTPClient

ws#

The websocket client utilized by this client that interacts with Adapt websocket events.

Type:

WebSocket

Parameters:
  • loop (asyncio.AbstractEventLoop) – The event loop the client should use. Defaults to what is returned by calling asyncio.get_event_loop().

  • session (aiohttp.ClientSession) – The aiohttp client session to use for the created HTTP client. If not provided, one is created for you.

  • server (AdaptServer) – The urls of the backend server. Defaults to the production server found at adapt.chat.

  • token (str) – The token to run the client with. Leave blank to delay specification of the token.

  • status (Status) – The status to set the client to when it connects to harmony. Defaults to Status.online.

async close()#

This function is a coroutine.

Closes the client, freeing up resources the client might have used. This is automatically called if you use run().

property connection#

The connection object that manages the connection to Adapt and cached models.

Type:

Connection

async create_guild(*, name, description=None, icon=None, banner=None, public=False, nonce=None)#

This function is a coroutine.

Creates a new guild.

Parameters:
  • name (str) – The name of the guild.

  • description (str) – The description of the guild. This is optional.

  • icon (bytes, path-like object, file-like object, or None) – The icon of the guild. This is optional.

  • banner (bytes, path-like object, file-like object, or None) – The banner of the guild. This is optional.

  • public (bool) – Whether the guild should be public. Defaults to False.

  • nonce (str) – An optional nonce for integrity. When the guild creation event is received through the websocket, the nonce will be included in the payload. This can be used to verify that the guild was created successfully.

Returns:

The guild that was created.

Return type:

Guild

classmethod create_user(*, username, display_name=None, email, password, server=('https://api.adapt.chat', 'wss://harmony.adapt.chat', 'https://convey.adapt.chat'), **options)#

This function is a coroutine.

Registers a new user account, and returns a new client created to interact with that account.

When using this in a context manager, async with await is unnecessary

# Recommended:
async with Client.create_user(...) as client:
    await client.start(TOKEN)

# Unnecessary:
async with await Client.create_user(...) as client:
    await client.start(TOKEN)

Otherwise, this should be treated as a coroutine:

client = await Client.create_user(...)
client.run(TOKEN)
Parameters:
  • username (str) – The username of the new account.

  • display_name (str or None) – The display name of the new account. Defaults to None (i.e. no display name).

  • email (str) – The email of the new account.

  • password (str) – The password of the new account.

  • server (AdaptServer) – The urls of the backend server. Defaults to the production server found at adapt.chat.

  • **options – Additional keyword-arguments to pass in when constructing the HTTP client (i.e. loop, session)

Returns:

The created client object.

Return type:

Client

async fetch_guild(guild_id, *, respect_cache=False, channels=False, members=False, roles=False)#

This function is a coroutine.

Fetches a guild directly from the API.

Parameters:
  • guild_id (int) – The guild ID to fetch.

  • respect_cache (bool) – If True, if the guild is found in the cache, it will be returned instead of fetching from the API. This will also mean the members, roles, and channels parameters will be ignored.

  • channels (bool) – If True, the guild’s channels will be fetched.

  • members (bool) – If True, the guild’s members will be fetched.

  • roles (bool) – If True, the guild’s roles will be fetched.

Returns:

The guild object that was fetched.

Return type:

Guild

async fetch_guilds(*, channels=False, members=False, roles=False)#

This function is a coroutine.

Fetches all guilds that the client is a member of.

Warning

This is an expensive process and has high ratelimits, so it should be used sparingly. Guild data is returned by the ready event, so it is usually unnecessary to call this method.

Parameters:
  • channels (bool) – If True, channel data will be fetched for each guild.

  • members (bool) – If True, member data will be fetched for each guild.

  • roles (bool) – If True, role data will be fetched for each guild.

Returns:

An iterable of guild objects that were fetched. This is a generator that lazily resolves the guilds into Guild objects.

Return type:

Iterable[Guild]

async fetch_relationships()#

This function is a coroutine.

Fetches all relationships between the client and other users directly from the API.

Returns:

An iterable of relationship objects that were fetched. This is a generator that lazily resolves the relationships into Relationship objects.

Return type:

Iterable[Relationship]

async fetch_user(user_id, *, respect_cache=False)#

This function is a coroutine.

Fetches a user directly from the API.

Parameters:
  • user_id (int) – The user ID to fetch.

  • respect_cache (bool) – If True, if the user is found in the cache, it will be returned instead of fetching from the API.

Returns:

The user object that was fetched, or None if no user was found.

Return type:

User | None

classmethod from_http(http, *, server=None, **kwargs)#

Creates a client from an HTTP client. This is used internally.

Parameters:
  • http (HTTPClient) – The HTTP client to create the client object with.

  • server (AdaptServer) – The urls of the backend server. Defaults to the production server found at adapt.chat.

  • **kwargs – Additional keyword arguments to pass into the client constructor.

Returns:

The created client object.

Return type:

Client

classmethod from_login(*, email, password, method='reuse', server=('https://api.adapt.chat', 'wss://harmony.adapt.chat', 'https://convey.adapt.chat'), **options)#

This function is a coroutine.

Logs in with the specified credentials, then returns a client to interact with that account.

When using this in a context manager, async with await is unnecessary

# Recommended:
async with Client.from_login(...) as client:
    await client.start(TOKEN)

# Unnecessary:
async with await Client.from_login(...) as client:
    await client.start(TOKEN)

Otherwise, this should be treated as a coroutine:

client = await Client.from_login(...)
client.run(TOKEN)
Parameters:
  • email (str) – The email of the account.

  • password (str) – The password of the account.

  • method (Literal['new', 'revoke', 'reuse']) – The method to use to retrieve the token. Defaults to ‘reuse’.

  • server (AdaptServer) – The urls of the backend server. Defaults to the production server found at adapt.chat.

  • **options – Additional keyword-arguments to pass in when constructing the HTTP client (i.e. loop, session)

Returns:

The created client object.

Return type:

Client

get_guild(guild_id)#

Retrieves a guild from the cache.

Parameters:

guild_id (int) – The guild ID to retrieve.

Returns:

The guild object that was retrieved, or None if no guild was found.

Return type:

Guild | None

get_partial_guild(guild_id)#

Creates a usable partial guild object that operates with only its ID.

This is useful for when you want to perform actions on a guild without having to ensure it is cached or fetch unnecessary guild data.

Parameters:

guild_id (int) – The guild ID to create the partial guild with.

Returns:

The partial guild object that was created.

Return type:

PartialGuild

get_partial_user(user_id)#

Creates a usable partial user object that operates with only its ID.

This is useful for when you want to perform actions on a user without having to ensure they are cached or fetch unnecessary user data.

Parameters:

user_id (int) – The user ID to create the partial user with.

Returns:

The partial user object that was created.

Return type:

PartialUser

get_relationship(user_id)#

Retrieves the relationship between the client and the user with the given ID from the cache.

Parameters:

user_id (int) – The user ID to retrieve.

Returns:

The relationship object that was retrieved, or None if no relationship was found.

Return type:

Relationship

get_user(user_id)#

Retrieves a user from the cache.

Parameters:

user_id (int) – The user ID to retrieve.

Returns:

The user object that was retrieved, or None if no user was found.

Return type:

User | None

property guilds#

An iterable of guilds that the client has cached.

Type:

Iterable[Guild]

property is_ready#

Whether the client has received the ready event from harmony yet.

Type:

bool

property latency#

The amount of time in seconds it took for the previous heartbeat to harmony (the websocket) to be acknowledged.

This is None if: - The client is not logged in. - The client has not yet sent a heartbeat to harmony. - The client has not yet received a heartbeat acknowledgement from harmony.

Type:

float

property latency_ns#

The equivalent of latency but in nanoseconds. This could yield more accurate measurements due to floating point precision errors in latency.

See also

latency

The equivalent of this property in seconds. See this for more information.

Type:

int

property relationships#

An iterable of relationships that the client has cached.

Type:

Iterable[Relationship]

run(token=None)#

Runs the client, logging in with the provided token and connecting to harmony. This is a blocking call.

Parameters:

token (str) – The token to log in with. If not provided, the token specified in the constructor is used.

property server#

The server the client retrieves all Adapt URLs from.

async start(token=None)#

This function is a coroutine.

Starts the client, logging in with the provided token and connecting to harmony.

Parameters:

token (str) – The token to log in with. If not provided, the token specified in the constructor is used.

async update_presence(*, status=...)#

This function is a coroutine.

Updates the client’s presence.

Parameters:

status (Status) – The new status to update the client’s presence with. Leave blank to keep the current status.

property user#

The user object that represents the user account the client is logged into.

This is None if the client is not logged in.

Type:

ClientUser | None

property users#

An iterable of users that the client has cached.

Type:

Iterable[User]

async wait_until_ready()#

This function is a coroutine.

Blocks the event loop until the client receives the ready event from harmony.

Returns:

The ready event that was dispatched.

Return type:

ReadyEvent

Server#

class adapt.AdaptServer(api, harmony, convey)#

Represents connection URLs or locations of the Adapt API server.

Parameters:
api#

Alias for field number 0

convey#

Alias for field number 2

copy_with(*, api=None, harmony=None, convey=None)#

Create a copy of this AdaptServer with the specified parameters replaced.

Parameters:
harmony#

Alias for field number 1

classmethod local()#

A AdaptServer instance representing a local Adapt API server with default ports extracted from Adapt’s source code.

This is useful for testing.

classmethod production()#

A AdaptServer instance representing the production Adapt API server (adapt.chat).

This is the default server used by the library.

Events#

class adapt.client.EventDispatcher#

Base class for receiving events and then dispatching them to event handlers registered on the client.

dispatch(event, *args, **kwargs)#

Dispatches an event to its registered listeners.

Parameters:
  • event (str) – The event to dispatch to.

  • *args – Positional arguments to pass into event handlers.

  • **kwargs – Keyword arguments to pass into event handlers.

event(callback)#

Registers an event listener on the client. This overrides any previous listeners for that event.

listen(*events, check=None, timeout=None, limit=None)#

Registers a weak listener for the given events. You may register as many of these as you want.

Parameters:
  • *events (str) – The events to listen for.

  • check (((*P.args, **P.kwargs) -> bool) | None) – An event check for when to call the callback. Leave empty to not have a check.

  • timeout (float | None) – The amount of seconds before this listener should expire. Leave empty to not have a timeout.

  • limit (int | None) – The amount of times the callback should be called before this listener should expire. Leave empty to not have a limit.

async on_connect()#

This function is a coroutine.

Called when the client establishes a connection with the websocket.

async on_event(event, *args, **kwargs)#

This function is a coroutine.

A “catch all” event handler for all events.

Parameters:
  • event (str) – The name of the event.

  • *args (Any) – The positional arguments for the event.

  • **kwargs (Any) – The keyword arguments for the event.

async on_guild_create(guild)#

This function is a coroutine.

Called when a guild is created.

Parameters:

guild (Guild) – The guild that was created.

async on_message(message)#

This function is a coroutine.

Called when a message is created.

Parameters:

message (Message) – The message that was created.

async on_ready(ready)#

This function is a coroutine.

Called when the client is connected and ready to receive events from the websocket.

Parameters:

ready (ReadyEvent) – Data received with the ready event.

async on_start()#

This function is a coroutine.

Called when the client starts to connect. This can be used to perform any necessary setup.

async wait_for(*events, check=None, timeout=None)#

This function is a coroutine.

Waits for an event to be dispatched.

Parameters:
  • *events (str) – The events to listen for.

  • check (((*P.args, **P.kwargs) -> bool) | None) – An event check for when to call the callback. Leave empty to not have a check.

  • timeout (float | None) – The amount of seconds before this listener should expire. Leave empty to not have a timeout.

Raises:

asyncio.TimeoutError – The event was not dispatched within the given timeout.

Returns:

The positional arguments of the dispatched event.

Return type:

*P.args

Event Utilities#

adapt.once(func)#

A decorator that registers an event listener to be called only once before being destroyed. This can be used within the client class.

Usage:

from adapt import Client, ReadyEvent, once

class MyClient(Client):
    @once
    async def on_ready(self, _event: ReadyEvent):
        print('Ready!')
Parameters:

func ((*P.args, **P.kwargs) -> Any) – The event listener.

Returns:

The event listener that will be called only once.

Return type:

(*P.args, **P.kwargs) -> Any

class adapt.ReadyEvent(*, connection, data)#

Represents the ready event from the gateway. This event is sent when the client is ready to receive events.

Note

Just like all models, this class is not meant to be constructed by the user. However, if for some reason you need to construct this class, it should be known that the constructor mutates the given connection state, which could lead to unexpected behaviour.

session_id#

The session ID used to identify the current websocket connection.

Type:

str

user#

The client user object.

Type:

ClientUser

guilds#

A list of guilds the client is in.

Type:

list[Guild]

dm_channels#

A list of DM channels the client is in.

Type:

list[DMChannel]

presences#

A list of presences the client has.

Type:

list[Presence]

relationships#

A list of relationships the client has with other users.

Type:

list[Relationship]

Models#

Object#

class adapt.Object(id, *, model_type=None)#

A generic Adapt object that has an ID.

Parameters:
  • id (int) – The ID of the object.

  • model_type (ModelType) – The type of model the object is. If not provided, the model type will be calculated from the ID. If it is provided, the ID will be modified to match the provided model type.

property created_at#

The time the object was created.

property id#

The ID of the object.

property model_type#

The type of model the object is.

User#

class adapt.User#

Represents an Adapt user.

username#

The user’s username.

Type:

str

bio#

The user’s custom bio.

Type:

str

async accept_friend_request()#

This function is a coroutine.

Accepts the incoming friend request from this user.

Returns:

The relationship created from accepting the friend request.

Return type:

Relationship

Raises:

TypeError – If there is no incoming friend request from this user.

property avatar#

The user’s avatar.

Type:

Asset

property banner#

The user’s banner.

Type:

Asset

async block()#

This function is a coroutine.

Blocks this user.

Returns:

The relationship created from blocking the user.

Return type:

Relationship

async create_dm()#

This function is a coroutine.

Creates a DM channel with this user. This makes the API call despite whether a DM channel already exists.

Returns:

The DM channel created.

Return type:

DMChannel

property created_at#

The time the object was created.

async decline_friend_request()#

This function is a coroutine.

Declines the incoming friend request from this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If there is no incoming friend request from this user.

property display_name#

The name displayed to refer to the user globally.

This falls back to username if the user has no display name.

Type:

str

property dm_channel#

The DM channel with this user, if it exists in the cache.

Type:

DMChannel

async fetch_message(message_id)#

This function is a coroutine.

Fetches a message from the channel.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

The message that was fetched.

Return type:

Message

property flags#

The user’s flags.

Type:

UserFlags

property has_display_name#

Whether the user explicitly has a display name configured.

Type:

bool

property id#

The ID of the object.

property is_bot#

Whether the user is a bot account.

Type:

bool

property mention#

The string used to mention the user. (<@id>)

Type:

str

property name#

The user’s username. This is an alias for username.

Deprecated since version 0.1.0: This property is officially named username and it is a good practice to use that instead of “name”.

Type:

str

property relationship#

The relationship between you and this user.

Returns None if no relationship exists.

Type:

Relationship

async remove_friend()#

This function is a coroutine.

Removes this user as a friend. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If this user is not a friend.

property resolved_name#

The resolved name for the user, displayed in clients to refer to the user.

  • For users, this is the same as display_name.

  • For members, this returns the user’s nickname with a fallback to display_name.

Type:

str

async revoke_friend_request()#

This function is a coroutine.

Revokes the outgoing friend request to this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If there is no outgoing friend request to this user.

async send(content=None, *, nonce=None)#

This function is a coroutine.

Sends a message to the channel.

Parameters:
  • content (str) – The content of the message to send.

  • nonce (str) – An optional nonce for integrity. When this message is received through the websocket, the nonce will be included in the message payload. This can be used to verify that the message was sent successfully.

Returns:

The message that was sent.

Return type:

Message

async send_friend_request()#

This function is a coroutine.

Sends a friend request to this user.

Returns:

The relationship created from sending the friend request.

Return type:

Relationship

async unblock()#

This function is a coroutine.

Unblocks this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If this user is not blocked.

ClientUser#

class adapt.ClientUser#

Represents the user object for the client user.

username#

The user’s username.

Type:

str

bio#

The user’s custom bio.

Type:

str

email#

The user’s email.

Type:

str

property avatar#

The user’s avatar.

Type:

Asset

property banner#

The user’s banner.

Type:

Asset

property created_at#

The time the object was created.

async delete(*, password)#

This function is a coroutine.

Deletes the client’s user account. This is irreversible.

Note

The account must be a user account; if it is a bot account, the bot account can only be deleted by the user account that owns it.

Parameters:

password (str) – The password of the user, required for security purposes.

Raises:

TypeError – The client user is a bot account.

property display_name#

The name displayed to refer to the user globally.

This falls back to username if the user has no display name.

Type:

str

async edit(*, username=..., display_name=..., avatar=..., banner=..., bio=...)#

This function is a coroutine.

Updates the client’s user information. Only the parameters passed will be updated.

Parameters:
  • username (str) – The new username to use.

  • display_name (str or None) – The new display name to use. If None, the display name will be removed.

  • avatar (bytes, path-like object, file-like object, or None) – The new avatar to use. If None, the avatar will be removed.

  • banner (bytes, path-like object, file-like object, or None) – The new banner to use. If None, the banner will be removed.

  • bio (str or None) – The new bio to use. If None, the bio will be removed.

Returns:

The updated client user.

Return type:

ClientUser

property flags#

The user’s flags.

Type:

UserFlags

property has_display_name#

Whether the user explicitly has a display name configured.

Type:

bool

property id#

The ID of the object.

property is_bot#

Whether the user is a bot account.

Type:

bool

property mention#

The string used to mention the user. (<@id>)

Type:

str

property name#

The user’s username. This is an alias for username.

Deprecated since version 0.1.0: This property is officially named username and it is a good practice to use that instead of “name”.

Type:

str

property resolved_name#

The resolved name for the user, displayed in clients to refer to the user.

  • For users, this is the same as display_name.

  • For members, this returns the user’s nickname with a fallback to display_name.

Type:

str

PartialUser#

class adapt.PartialUser#

A partial user object which operates with only an ID.

This is useful for performing operations on users without having to fetch them first.

async accept_friend_request()#

This function is a coroutine.

Accepts the incoming friend request from this user.

Returns:

The relationship created from accepting the friend request.

Return type:

Relationship

Raises:

TypeError – If there is no incoming friend request from this user.

async block()#

This function is a coroutine.

Blocks this user.

Returns:

The relationship created from blocking the user.

Return type:

Relationship

async create_dm()#

This function is a coroutine.

Creates a DM channel with this user. This makes the API call despite whether a DM channel already exists.

Returns:

The DM channel created.

Return type:

DMChannel

property created_at#

The time the object was created.

async decline_friend_request()#

This function is a coroutine.

Declines the incoming friend request from this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If there is no incoming friend request from this user.

property dm_channel#

The DM channel with this user, if it exists in the cache.

Type:

DMChannel

async fetch_message(message_id)#

This function is a coroutine.

Fetches a message from the channel.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

The message that was fetched.

Return type:

Message

property id#

The ID of the object.

property relationship#

The relationship between you and this user.

Returns None if no relationship exists.

Type:

Relationship

async remove_friend()#

This function is a coroutine.

Removes this user as a friend. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If this user is not a friend.

async revoke_friend_request()#

This function is a coroutine.

Revokes the outgoing friend request to this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If there is no outgoing friend request to this user.

async send(content=None, *, nonce=None)#

This function is a coroutine.

Sends a message to the channel.

Parameters:
  • content (str) – The content of the message to send.

  • nonce (str) – An optional nonce for integrity. When this message is received through the websocket, the nonce will be included in the message payload. This can be used to verify that the message was sent successfully.

Returns:

The message that was sent.

Return type:

Message

async unblock()#

This function is a coroutine.

Unblocks this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If this user is not blocked.

Relationship#

class adapt.Relationship#

Represents a relationship between you, the client user, and another user.

async accept()#

This function is a coroutine.

Accepts this relationship if it is an incoming friend request. This is equivalent to calling User.accept_friend_request().

Returns:

The relationship created from accepting the friend request.

Return type:

Relationship

Raises:

TypeError – If the relationship type is not incoming_request.

async delete()#

This function is a coroutine.

Deletes this relationship:

  • If the relationship type is friend, this will unfriend the user.

  • If the relationship type is outgoing_request, this will cancel the outgoing friend request.

  • If the relationship type is incoming_request, this will decline the incoming friend request.

  • If the relationship type is blocked, this will unblock the user.

property type#

The type of this relationship.

Type:

RelationshipType

property user#

The user that this relationship is with.

Type:

User

Guild#

class adapt.Guild#

Represents a guild in Adapt.

name#

The name of the guild.

Type:

str

description#

The description of the guild.

Type:

str | None

owner_id#

The ID of the user that owns the guild.

Type:

int

vanity_code#

The vanity URL code of the guild. This solely includes the code, not the full URL. This is None if the guild does not have a vanity URL.

Type:

str | None

property banner#

The guild’s banner.

Type:

Asset

property cache_integrity#

Returns the integrity of the guild’s cache.

This is a NamedTuple with the following boolean attributes:

  • members: Whether the guild’s members are cached.

  • roles: Whether the guild’s roles are cached.

  • channels: Whether the guild’s channels are cached.

property channels#

An iterable of the guild’s channels.

Type:

Iterable[GuildChannel]

property created_at#

The time the object was created.

async delete(*, password=...)#

This function is a coroutine.

Deletes the guild.

Parameters:

password (str) – Your account password. This must be specified when deleting user accounts for security purposes. This should not be specified when deleting bot accounts.

async edit(*, name=..., description=..., icon=..., banner=..., public=...)#

This function is a coroutine.

Edits the properties for the guild. Only the parameters passed will be updated.

Parameters:
  • name (str) – The new name for the guild.

  • description (str) – The new description for the guild. Set to None to remove the description.

  • icon (bytes, path-like object, file-like object, or None) – The new icon for the guild. Set to None to remove the icon.

  • banner (bytes, path-like object, file-like object, or None) – The new banner for the guild. Set to None to remove the banner.

  • public (bool) – Whether the guild is public or not.

Returns:

The updated guild object.

Return type:

Guild

async fetch_channel(channel_id, *, respect_cache=True)#

This function is a coroutine.

Fetches the channel with the given ID from the API.

Parameters:
  • channel_id (int) – The ID of the channel to fetch.

  • respect_cache (bool) – Whether to respect the cache or not. If True, the cache will be checked first.

Returns:

The channel with the given ID.

Return type:

GuildChannel

async fetch_member(member_id, *, respect_cache=True)#

This function is a coroutine.

Fetches the member with the given ID from the API.

Parameters:
  • member_id (int) – The ID of the member to fetch.

  • respect_cache (bool) – Whether to respect the cache or not. If True, the cache will be checked first.

Returns:

The member with the given ID.

Return type:

Member

property flags#

Special properties and features about the guild.

Type:

GuildFlags

get_channel(channel_id)#

Returns the channel with the given ID, resolved from the cache.

Parameters:

channel_id (int) – The ID of the channel to get.

Returns:

The channel with the given ID, or None if not found in the cache.

Return type:

GuildChannel | None

get_member(member_id)#

Returns the member with the given ID, resolved from the cache.

Parameters:

member_id (int) – The ID of the member to get.

Returns:

The member with the given ID, or None if not found in the cache.

Return type:

Member | None

get_partial_member(member_id)#

Creates a usable partial member object that operates with only its ID.

This is useful for when you want to perform actions on a member without having to ensure it is cached or fetch unnecessary guild or member data.

Parameters:

member_id (int) – The user ID to create the partial member with.

Returns:

The partial member object that was created.

Return type:

PartialMember

property icon#

The guild’s icon.

Type:

Asset

property id#

The ID of the object.

async kick(member)#

This function is a coroutine.

Kicks the member from the guild. You must have the Permissions.kick_members permission to do this.

Parameters:

member (Member-like) – The member to kick.

async leave()#

This function is a coroutine.

Leaves the guild.

property me#

The member that represents the client in the guild, if available in cache.

This is equivalent to guild.get_member(client.user.id).

Type:

Member

property members#

An iterable of the guild’s members.

Type:

Iterable[Member]

property owner#

The resolved member object of the guild owner, if available in cache.

Type:

Member | None

property public#

Whether the guild is public.

Type:

bool

property text_channels#

An iterator of the guild’s text-based channels.

Type:

Iteratable[TextBasedGuildChannel]

property verified#

Whether the guild is verified.

Type:

bool

PartialGuild#

class adapt.PartialGuild#

A partial guild object which operates with only an ID.

This is useful for performing operations on guilds without having to fetch them first.

Note

Unlike a full Guild, partial guilds will not perform any permission checks locally and will instead rely on the API to perform them. This could result in more unnecessary API calls being made.

Note

This is not to be confused with the official PartialGuild model in the Adapt API protocol, which is a guild without member, channel, and role data. This is a guild object that only operates with an ID.

property created_at#

The time the object was created.

async delete(*, password=...)#

This function is a coroutine.

Deletes the guild.

Parameters:

password (str) – Your account password. This must be specified when deleting user accounts for security purposes. This should not be specified when deleting bot accounts.

async edit(*, name=..., description=..., icon=..., banner=..., public=...)#

This function is a coroutine.

Edits the properties for the guild. Only the parameters passed will be updated.

Note

Nothing is returned from this method. If you wish to get the updated guild object, perform the edit on a full Guild object instead.

Parameters:
  • name (str) – The new name for the guild.

  • description (str) – The new description for the guild. Set to None to remove the description.

  • icon (bytes, path-like object, file-like object, or None) – The new icon for the guild. Set to None to remove the icon.

  • banner (bytes, path-like object, file-like object, or None) – The new banner for the guild. Set to None to remove the banner.

  • public (bool) – Whether the guild is public or not.

get_partial_member(member_id)#

Creates a usable partial member object that operates with only its ID.

This is useful for when you want to perform actions on a member without having to ensure it is cached or fetch unnecessary guild or member data.

Parameters:

member_id (int) – The user ID to create the partial member with.

Returns:

The partial member object that was created.

Return type:

PartialMember

property id#

The ID of the object.

async kick(member)#

This function is a coroutine.

Kicks the member from the guild. You must have the Permissions.kick_members permission to do this.

Parameters:

member (Member-like) – The member to kick.

async leave()#

This function is a coroutine.

Leaves the guild.

Member#

class adapt.Member#

Represents a member of a guild.

async accept_friend_request()#

This function is a coroutine.

Accepts the incoming friend request from this user.

Returns:

The relationship created from accepting the friend request.

Return type:

Relationship

Raises:

TypeError – If there is no incoming friend request from this user.

property avatar#

The user’s avatar.

Type:

Asset

property banner#

The user’s banner.

Type:

Asset

async block()#

This function is a coroutine.

Blocks this user.

Returns:

The relationship created from blocking the user.

Return type:

Relationship

async create_dm()#

This function is a coroutine.

Creates a DM channel with this user. This makes the API call despite whether a DM channel already exists.

Returns:

The DM channel created.

Return type:

DMChannel

property created_at#

The time the object was created.

async decline_friend_request()#

This function is a coroutine.

Declines the incoming friend request from this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If there is no incoming friend request from this user.

property display_name#

The name displayed to refer to the user globally.

This falls back to username if the user has no display name.

Type:

str

property dm_channel#

The DM channel with this user, if it exists in the cache.

Type:

DMChannel

async fetch_message(message_id)#

This function is a coroutine.

Fetches a message from the channel.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

The message that was fetched.

Return type:

Message

property flags#

The user’s flags.

Type:

UserFlags

property has_display_name#

Whether the user explicitly has a display name configured.

Type:

bool

property id#

The ID of the object.

property is_bot#

Whether the user is a bot account.

Type:

bool

property is_me#

Whether this member is the client user.

async kick()#

This function is a coroutine.

Kicks the member from the guild. You must have the Permissions.kick_members permission to do this. This is a shortcut for calling Guild.kick() with this member.

property mention#

The string used to mention the user. (<@id>)

Type:

str

property name#

The user’s username. This is an alias for username.

Deprecated since version 0.1.0: This property is officially named username and it is a good practice to use that instead of “name”.

Type:

str

property relationship#

The relationship between you and this user.

Returns None if no relationship exists.

Type:

Relationship

async remove_friend()#

This function is a coroutine.

Removes this user as a friend. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If this user is not a friend.

property resolved_name#

The member’s display name.

This is their nickname if they have one, otherwise it is their display_name.

Type:

str

async revoke_friend_request()#

This function is a coroutine.

Revokes the outgoing friend request to this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If there is no outgoing friend request to this user.

async send(content=None, *, nonce=None)#

This function is a coroutine.

Sends a message to the channel.

Parameters:
  • content (str) – The content of the message to send.

  • nonce (str) – An optional nonce for integrity. When this message is received through the websocket, the nonce will be included in the message payload. This can be used to verify that the message was sent successfully.

Returns:

The message that was sent.

Return type:

Message

async send_friend_request()#

This function is a coroutine.

Sends a friend request to this user.

Returns:

The relationship created from sending the friend request.

Return type:

Relationship

async unblock()#

This function is a coroutine.

Unblocks this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If this user is not blocked.

property user#

The user that this member represents.

Although members are a subclass of users, this property is provided for completeness.

Type:

User

PartialMember#

class adapt.PartialMember#

Represents a partial member of a guild.

This is useful for performing operations on members without having to fetch them first.

guild#

The guild that the member is in. This may be a partial guild.

Type:

PartialGuild

async accept_friend_request()#

This function is a coroutine.

Accepts the incoming friend request from this user.

Returns:

The relationship created from accepting the friend request.

Return type:

Relationship

Raises:

TypeError – If there is no incoming friend request from this user.

async block()#

This function is a coroutine.

Blocks this user.

Returns:

The relationship created from blocking the user.

Return type:

Relationship

async create_dm()#

This function is a coroutine.

Creates a DM channel with this user. This makes the API call despite whether a DM channel already exists.

Returns:

The DM channel created.

Return type:

DMChannel

property created_at#

The time the object was created.

async decline_friend_request()#

This function is a coroutine.

Declines the incoming friend request from this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If there is no incoming friend request from this user.

property dm_channel#

The DM channel with this user, if it exists in the cache.

Type:

DMChannel

async fetch_message(message_id)#

This function is a coroutine.

Fetches a message from the channel.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

The message that was fetched.

Return type:

Message

property id#

The ID of the object.

property is_me#

Whether this member is the client user.

async kick()#

This function is a coroutine.

Kicks the member from the guild. You must have the Permissions.kick_members permission to do this. This is a shortcut for calling Guild.kick() with this member.

property relationship#

The relationship between you and this user.

Returns None if no relationship exists.

Type:

Relationship

async remove_friend()#

This function is a coroutine.

Removes this user as a friend. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If this user is not a friend.

async revoke_friend_request()#

This function is a coroutine.

Revokes the outgoing friend request to this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If there is no outgoing friend request to this user.

async send(content=None, *, nonce=None)#

This function is a coroutine.

Sends a message to the channel.

Parameters:
  • content (str) – The content of the message to send.

  • nonce (str) – An optional nonce for integrity. When this message is received through the websocket, the nonce will be included in the message payload. This can be used to verify that the message was sent successfully.

Returns:

The message that was sent.

Return type:

Message

async unblock()#

This function is a coroutine.

Unblocks this user. This is a checked-equivalent of Relationship.delete().

Raises:

TypeError – If this user is not blocked.

PartialMessageable#

class adapt.PartialMessageable#

Represents a channel tha t can be a medium for text-based communication that operates with only its channel ID.

This is useful for performing messaging operations on channels without having to fetch them first or guarantee that they are cached.

channel_id#

The ID of the channel.

Type:

int

async fetch_message(message_id)#

This function is a coroutine.

Fetches a message from the channel.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

The message that was fetched.

Return type:

Message

async send(content=None, *, nonce=None)#

This function is a coroutine.

Sends a message to the channel.

Parameters:
  • content (str) – The content of the message to send.

  • nonce (str) – An optional nonce for integrity. When this message is received through the websocket, the nonce will be included in the message payload. This can be used to verify that the message was sent successfully.

Returns:

The message that was sent.

Return type:

Message

TextChannel#

class adapt.TextChannel#

Represents a text-based guild channel in Adapt.

topic#

The topic of the channel, if any.

Type:

str | None

nsfw#

Whether the channel is NSFW.

Type:

bool

locked#

Whether the channel is locked. Only people with the manage_channels permission can send messages in locked channels.

Type:

bool

property created_at#

The time the object was created.

async delete()#

This function is a coroutine.

Deletes the channel. You must have the manage_channels permission to do this.

async fetch_message(message_id)#

This function is a coroutine.

Fetches a message from the channel.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

The message that was fetched.

Return type:

Message

property id#

The ID of the object.

property is_locked#

Whether the channel is locked.

This is an alias for locked. and is provided for consistency.

Type:

bool

property is_nsfw#

Whether the channel is NSFW.

This is an alias for nsfw. and is provided for consistency.

Type:

bool

property mention#

A string that allows you to mention the channel.

Type:

str

async send(content=None, *, nonce=None)#

This function is a coroutine.

Sends a message to the channel.

Parameters:
  • content (str) – The content of the message to send.

  • nonce (str) – An optional nonce for integrity. When this message is received through the websocket, the nonce will be included in the message payload. This can be used to verify that the message was sent successfully.

Returns:

The message that was sent.

Return type:

Message

property slowmode#

The slowmode of the channel, in seconds. This is 0.0 if the channel has no slowmode.

Type:

float

property slowmode_ms#

The slowmode of the channel, in milliseconds. This is 0 if the channel has no slowmode.

Type:

int

AnnouncementChannel#

class adapt.AnnouncementChannel#

Represents an announcement channel in a guild in Adapt.

property created_at#

The time the object was created.

async delete()#

This function is a coroutine.

Deletes the channel. You must have the manage_channels permission to do this.

async fetch_message(message_id)#

This function is a coroutine.

Fetches a message from the channel.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

The message that was fetched.

Return type:

Message

property id#

The ID of the object.

property is_locked#

Whether the channel is locked.

This is an alias for locked. and is provided for consistency.

Type:

bool

property is_nsfw#

Whether the channel is NSFW.

This is an alias for nsfw. and is provided for consistency.

Type:

bool

property mention#

A string that allows you to mention the channel.

Type:

str

async send(content=None, *, nonce=None)#

This function is a coroutine.

Sends a message to the channel.

Parameters:
  • content (str) – The content of the message to send.

  • nonce (str) – An optional nonce for integrity. When this message is received through the websocket, the nonce will be included in the message payload. This can be used to verify that the message was sent successfully.

Returns:

The message that was sent.

Return type:

Message

property slowmode#

The slowmode of the channel, in seconds. This is 0.0 if the channel has no slowmode.

Type:

float

property slowmode_ms#

The slowmode of the channel, in milliseconds. This is 0 if the channel has no slowmode.

Type:

int

DMChannel#

class adapt.DMChannel#

Represents a DM channel in Adapt.

type#

The type of the channel. is_dm for this value will always be True.

Type:

ChannelType

property can_manage#

Whether the client can manage the channel.

This will always be True for DM channels.

Type:

bool

property created_at#

The time the object was created.

async delete()#

This function is a coroutine.

Deletes the channel.

async fetch_message(message_id)#

This function is a coroutine.

Fetches a message from the channel.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

The message that was fetched.

Return type:

Message

property id#

The ID of the object.

property recipient#

The other recipient of this DM channel.

This is a shortcut for calling Connection.get_user() with recipient_id. If the user is not cached, this will return None.

Type:

User

property recipient_id#

The ID of the other recipient of this DM channel.

Type:

int

property recipients#

The recipients of the channel, including yourself.

This is a shortcut for calling Connection.get_user() with each ID in recipient_ids. Users that are not cached will be excluded from the list.

Type:

list`[:class:.User`]

async send(content=None, *, nonce=None)#

This function is a coroutine.

Sends a message to the channel.

Parameters:
  • content (str) – The content of the message to send.

  • nonce (str) – An optional nonce for integrity. When this message is received through the websocket, the nonce will be included in the message payload. This can be used to verify that the message was sent successfully.

Returns:

The message that was sent.

Return type:

Message

Message#

class adapt.Message#

Represents a message in Adapt.

content#

The content of the message. If no content exists, an empty string is returned.

Type:

str

type#

The type of the message.

Type:

MessageType

flags#

Special properties about the message.

Type:

MessageFlags

stars#

The number of stars the message has accumulated.

Type:

int

property author#

The author of the message.

If an author is not applicable, or resolved author data was not provided and the author is not cached, this will be None.

Otherwise, if the message was sent in a guild, this will be a Member. If it was sent in a private channel, this will be a User.

Type:

User | Member | None

property created_at#

The time the object was created.

async delete()#

This function is a coroutine.

Deletes the message.

async edit(*, content=...)#

This function is a coroutine.

Edits the message.

Parameters:

content (str) – The new content of the message.

Returns:

The edited message.

Return type:

Message

property guild#

The guild that the message was sent in, if applicable.

Type:

Guild | None

property id#

The ID of the object.

PartialMessage#

class adapt.PartialMessage(*, channel, id)#

Represents a message in Adapt that only operates with a channel, message ID, and potentially a revision ID.

This is useful for performing operations on messages without having to fetch them first.

channel#

The channel that the message belongs to.

Type:

TextChannel | PrivateChannel | PartialMessageable

property created_at#

The time the object was created.

async delete()#

This function is a coroutine.

Deletes the message.

async edit(*, content=...)#

This function is a coroutine.

Edits the message.

Parameters:

content (str) – The new content of the message.

Returns:

The edited message.

Return type:

Message

property id#

The ID of the object.

Asset#

class adapt.Asset#

Represents an asset from Adapt’s CDN, convey.

url#

The URL of the asset.

Type:

str

async read(*, cache=True)#

This function is a coroutine.

Downloads the asset’s contents into raw bytes. This cannot be used if the asset is stateless.

Note

For assets that are cached, the cache is held on the asset object and not the connection. This means that two different asset objects may not share the same cache.

Parameters:

cache (bool) – Whether to cache the asset. Defaults to True. If this is enabled, future calls to read will return the cached bytes instead of downloading the asset again.

Returns:

The raw bytes of the asset.

Return type:

bytes

Raises:

TypeError – If the asset is stateless.

async save(fp, *, cache=True, seek_begin=True)#

This function is a coroutine.

Downloads the asset’s contents and saves it to a file. This cannot be used if the asset is stateless.

Note

For assets that are cached, the cache is held on the asset object and not the connection. This means that two different asset objects may not share the same cache.

Parameters:
  • fp (str, pathlib.Path, or file-like object) – The file path or file-like object to save the asset to.

  • cache (bool) – Whether to cache the asset. Defaults to True. If this is enabled, future calls to save will not download the asset again.

  • seek_begin (bool) – Whether to seek to the beginning of the file after writing. Defaults to True.

Returns:

The number of bytes written to the file.

Return type:

int

Raises:

TypeError

  • If the file-like object does not support the write method. - If the asset is stateless.

Base Classes#

Messageable#

class adapt.Messageable#

Represents a channel or model that can be a medium for text-based communication.

async fetch_message(message_id)#

This function is a coroutine.

Fetches a message from the channel.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

The message that was fetched.

Return type:

Message

async send(content=None, *, nonce=None)#

This function is a coroutine.

Sends a message to the channel.

Parameters:
  • content (str) – The content of the message to send.

  • nonce (str) – An optional nonce for integrity. When this message is received through the websocket, the nonce will be included in the message payload. This can be used to verify that the message was sent successfully.

Returns:

The message that was sent.

Return type:

Message

GuildChannel#

class adapt.GuildChannel#

Represents a guild channel in Adapt.

This is the base class for all types of guild channels, and should not be used directly.

Channels are the primary way to communicate with other users in Adapt. They can be either text-based, voice-based, or a category of channels.

type#

The type of the channel. ChannelType.is_guild for this value will always be True.

Type:

ChannelType

guild#

The guild that the channel belongs to.

Type:

Guild

parent_id#

The ID of the parent category that the channel belongs to, if any.

Type:

int | None

name#

The name of the channel.

Type:

str

position#

The position of the channel in the channel list. See the essence documentation for more information.

Type:

int

property created_at#

The time the object was created.

async delete()#

This function is a coroutine.

Deletes the channel. You must have the manage_channels permission to do this.

property id#

The ID of the object.

PrivateChannel#

class adapt.PrivateChannel#

Represents a DM or group channel in Adapt.

This is the base class for all types of private channels, and should not be used directly.

type#

The type of the channel. Can be either dm or group. ChannelType.is_dm for this value will always be True.

Type:

ChannelType

abstract property can_manage#

Whether the client can manage the channel.

Type:

bool

property created_at#

The time the object was created.

async delete()#

This function is a coroutine.

Deletes the channel.

property id#

The ID of the object.

property recipients#

The recipients of the channel, including yourself.

This is a shortcut for calling Connection.get_user() with each ID in recipient_ids. Users that are not cached will be excluded from the list.

Type:

list`[:class:.User`]

Enums#

Standard Enums#

class adapt.ModelType#

This is an enum.

Enumeration of model types.

guild#

The model is a Guild.

user#

The model is a User.

channel#

The model is a Channel.

message#

The model is a Message.

attachment#

The model is an Attachment.

role#

The model is a Role.

internal#

The model is an internal model.

unknown#

The model type is unknown.

class adapt.Status#

This is an enum.

The status of a user’s presence.

online#

The user is online.

idle#

The user is idle.

dnd#

The user is has enabled Do Not Disturb.

offline#

The user is offline.

class adapt.RelationshipType#

This is an enum.

The type of a relationship.

friend#

The user is your friend.

outgoing_request#

You have sent a friend request to the user.

incoming_request#

You have received a friend request from the user.

blocked#

You have blocked the user.

class adapt.ChannelType#

This is an enum.

The type of a channel.

text#

The channel is a text channel.

announcement#

The channel is an announcement channel.

voice#

The channel is a voice channel.

category#

The channel is a category channel.

dm#

The channel is a DM channel.

group#

The channel is a group DM channel.

class adapt.MessageType#

This is an enum.

default

A normal message.

join

A join message, sent when a user joins either a group DM or a guild.

leave

A leave message, sent when a user leaves either a group DM or a guild.

pin

A message that indicates another message has been pinned.

Bitflag Enums#

class adapt.Bitflags(value=..., **flags)#

The base class that all bitflag classes inherit from. This class is not meant to be used directly.

Bitflags are a way to represent multiple boolean values in a single integer. This class provides a way to easily read and manipulate these boolean values.

Parameters:
  • value (int) – The initial bits. If not provided, the default value will be used (typically 0 unless specified).

  • **flags (bool) – The overrides for each flag. If a flag is not provided, it will be set to False.

value#

The current bits.

Type:

int

Examples

We will use the Permissions class as an example.

Create a new permissions instance with specific flags:

permissions = Permissions(view_channel=True, send_messages=True)

Create a new permissions instance with a specific value:

permissions = Permissions(5)  # Equivalent to Permissions(view_channel=True, send_messages=True)

Read the value of a specific flag:

permissions.view_channel  # True
permissions.add_reactions  # False

Set the value of a specific flag:

permissions.view_channel = False
permissions.view_channel  # False

# Using the `del` keyword will set the flag to False
del permissions.view_channel  # Equivalent to permissions.view_channel = False

Create a new permissions instance from another:

permissions = Permissions(view_channel=True, send_messages=True)
modified = permissions.copy_with(send_messages=False)

permissions.send_messages  # True
modified.send_messages  # False

Helper methods are also provided to make it easier to work with bitflags:

no_permissions = Permissions.none()  # Equivalent to Permissions(0)
all_permissions = Permissions.all()  # Enable all flags
default_permissions = Permissions.default()  # Use the default value

Turn a permissions instance into a dictionary:

permissions = Permissions(view_channel=True, send_messages=True)
dict(permissions)  # {'view_channel': True, 'send_messages': True, 'add_reactions': False, ...}

# Turn it into a list of enabled flags
[name for name, value in permissions if value]  # ['view_channel', 'send_messages']
classmethod all()#

Creates a new instance with all flags set to True.

Returns:

The new instance.

Return type:

Bitflags

copy_with(**overrides)#

Returns a copy of this instance with the given flag overrides applied.

Parameters:

**overrides (bool) – The flags to override.

Returns:

The new instance.

Return type:

Bitflags

classmethod default()#

Creates a new instance with the default flags.

Returns:

The new instance.

Return type:

Bitflags

classmethod none()#

Creates a new instance with all flags set to False.

Returns:

The new instance.

Return type:

Bitflags

class adapt.UserFlags(value=..., **flags)#

This is represented using Bitflags.

Represents special properties about a user.

bot#

Whether the user is a bot.

Type:

bool

class adapt.PrivacyConfiguration(value=..., **flags)#

This is represented using Bitflags.

Represents the privacy configuration of a user.

friends#

This configuration is public for friends.

Type:

bool

mutual_friends#

This configuration is public for mutual friends (friends of friends).

Type:

bool

guild_members#

This configuration is public for users who share a guild with you.

Type:

bool

everyone#

This configuration is public for everyone. This overrides all other configurations.

Type:

bool

class adapt.GuildFlags(value=..., **flags)#

This is represented using Bitflags.

Represents extra properties and features about a guild.

public#

The guild is a public guild.

Type:

bool

verified#

The guild is verified or official guild.

Type:

bool

vanity_url#

The guild has a vanity invite URL.

Type:

bool

class adapt.MessageFlags(value=..., **flags)#

This is represented using Bitflags.

Represents extra properties and features about a message.

pinned#

The message is pinned.

Type:

bool

system#

The message is a system message.

Type:

bool

crosspost#

The message is a subscribed crosspost from an announcement channel.

Type:

bool

published#

This message has been published to subscribed channels in an announcement channel.

Type:

bool

class adapt.RoleFlags(value=..., **flags)#

This is represented using Bitflags.

Represents extra properties and features about a role.

hoisted#

Whether the role is hoisted, or shown separately, in the members list.

Type:

bool

managed#

Whether the role is managed. Managed roles cannot be edited or deleted.

Type:

bool

mentionable#

Whether the role is mentionable.

Type:

bool

default_role#

Whether the role is the default role for everyone.

Type:

bool

class adapt.Permissions(value=..., **flags)#

This is represented using Bitflags.

Represents a set of permissions.

view_channel#

People with this permission can view channels and receive events from them.

Type:

bool

view_message_history#

People with this permission can view the message history of channels. The view_channel permission is not necessarily required to view the message history, however it means you cannot receive or send new messages in the channel.

Type:

bool

send_messages#

People with this permission can send messages in channels. The view_channel permission is required to send messages.

Type:

bool

manage_messages#

People with this permission can manage messages sent by other people. This allows for the following:

  • Deleting messages sent by others

  • Deleting attachments or embeds sent by others

  • Removing reactions of others

  • Unpublishing messages sent by others (Announcement channels only)

Note that anyone can still delete their own messages.

Type:

bool

attach_files#

People with this permission can attach files to messages.

Type:

bool

send_embeds#

People with this permission can send rich embeds or have embed links automatically appear.

Type:

bool

add_reactions#

People with this permission can add new reactions to messages. Note that users without this permission can still react to already existing reactions.

Type:

bool

pin_messages#

People with this permission can pin and unpin messages.

Type:

bool

star_messages#

People with this permission can star and unstar messages.

Type:

bool

publish_messages#

People with this permission can publish messages to the announcement feed.

Type:

bool

modify_channels#

People with this permission can manage settings of channels.

Type:

bool

manage_channels#

People with this permission can manage channels.

Type:

bool

manage_webhooks#

People with this permission can create, edit, and delete webhooks.

Type:

bool

manage_emojis#

People with this permission can create, edit, and delete emojis.

Type:

bool

manage_starboard#

People with this permission can delete starboard posts, or disable the starboard completely.

Type:

bool

manage_guild#

People with this permission can manage the guild’s settings.

Type:

bool

manage_roles#

People with this permission can manage the guild’s roles. They will be able to change the permissions of any roles below their top role, and they will be forbidden to grant or deny any permissions they do not have themselves. They can also assign and remove any roles to other members, as long as the target role is below their top role.

Type:

bool

create_invites#

People with this permission can create invites to the guild.

Type:

bool

manage_invites#

People with this permission can revoke or pause invites of any channel in the guild. This does not take into account the create_invites permission, meaning they can revoke invites even if they cannot create them.

Type:

bool

use_external_emojis#

People with this permission can use emojis found in other servers.

Type:

bool

change_nickname#

People with this permission can change their own nickname.

Type:

bool

manage_nicknames#

People with this permission can change the nickname of other people.

Type:

bool

timeout_members#

People with this permission can timeout and untimeout members that are lower than them in role hierarchy.

Type:

bool

kick_members#

People with this permission can kick members that are lower than them in role hierarchy.

Type:

bool

ban_members#

People with this permission can ban and unban members that are lower than them in role hierarchy.

Type:

bool

bulk_delete_messages#

People with this permission can delete or purge messages in bulk. Unlike Discord, the API allows for up to any number of messages to be deleted at a time.

Type:

bool

view_audit_log#

People with this permission can view an audit log of past moderation or other privileged actions.

Type:

bool

privileged_mentions#

People with this permission can mention large groups of people. This means mentioning everyone under a non-mentionable role or mentioning everyone.

Type:

bool

connect#

People with this permission can connect to a voice channel.

Type:

bool

speak#

People with this permission can speak in a voice channel.

Type:

bool

mute_members#

People with this permission can mute other members in a voice channel.

Type:

bool

deafen_members#

People with this permission can deafen other members in a voice channel.

Type:

bool

administrator#

People with this permission have the ability to override all permissions and any channel. This means that despite any overwrites, they will have all permissions throughout the entire guild.

Type:

bool

Utility Functions#

adapt.util.extract_user_id_from_token(token, /)#

Extracts the user ID associated with the given authentication token.

Parameters:

token (str) – The token to parse.

Returns:

The snowflake ID of the associated user.

Return type:

int

Raises:

ValueError – Received a malformed token.

adapt.util.find(iterable, predicate)#

Finds the first element in an iterable that satisfies the given predicate.

Parameters:
  • iterable (Iterable[T]) – The iterable to search through.

  • predicate ((item: T) -> bool) – The predicate to use to find the element.

Returns:

The first element that satisfies the predicate, or None if no such element is found.

Return type:

T | None

adapt.util.snowflake_model_type(snowflake, /)#

Extracts the model type of the given Adapt snowflake.

Parameters:

snowflake (int) – The snowflake to extract the model type from.

Returns:

The model type associated with the snowflake.

Return type:

ModelType

adapt.util.snowflake_time(snowflake, /)#

Converts an Adapt snowflake to a datetime object.

Parameters:

snowflake (int) – The snowflake to convert.

Returns:

The datetime object representing the snowflake’s creation time.

Return type:

datetime.datetime