API Reference#

Client#

class voltage.Client(*, cache_message_limit: int = 5000)[source]#

Base voltage client.

cache_message_limit#

The maximum amount of messages to cache.

Type:

int

user#

The user of the client.

Type:

User

members#

The members the client has cached.

Type:

List[Member]

servers#

The servers the client is in.

Type:

List[Server]

users#

The users the client has cached.

Type:

List[User]

channels#

The channels the client has cached.

Type:

List[Channel]

listen:

Registers a function to listen for an event.

run:

Runs the client.

property channels: list[Any]#

The list of channels the client has cached.

error(event: str)[source]#

Registers a function to handle errors for a specific non-raw event.

This function is meant to be used as a decorator.

Parameters:

event (str) – The event to handle errors for.

Examples

@client.error("message")
async def message_error(error, message):
    if isinstance(error, IndexError): # You probably don't want to handle all the index errors like this but this is just an example.
        await message.reply("Not enough arguments.")
get_channel(channel_id: str) Channel | None[source]#

Gets a channel from the cache by ID.

Parameters:

channel_id (str) – The ID of the channel.

Returns:

The channel.

Return type:

Optional[Channel]

get_server(server_id: str) Server | None[source]#

Gets a server from the cache by ID.

Parameters:

server_id (str) – The ID of the server.

Returns:

The server.

Return type:

Optional[Server]

get_user(user: str) User | None[source]#

Gets a user from the cache by ID, mention or name.

Parameters:

user (str) – The ID, mention or name of the user.

Returns:

The user.

Return type:

Optional[User]

listen(event: str, *, raw: bool = False)[source]#

Registers a function to listen for an event.

This function is meant to be used as a decorator.

Parameters:
  • func (Callable[..., Any]) – The function to call when the event is triggered.

  • event (str) – The event to listen for.

  • raw (bool) – Whether or not to listen for raw events.

Examples

@client.listen("message")
async def any_name_you_want(message):
    if message.content == "ping":
        await message.channel.send("pong")

# example of a raw event
@client.listen("message", raw=True)
async def raw(payload):
    if payload["content"] == "ping":
        await client.http.send_message(payload["channel"], "pong")
property members: list[Member]#

The list of members the client has cached.

run(token: str, *, bot: bool = True, banner: bool = True)[source]#

Run the client.

Parameters:
  • token (str) – The bot token.

  • bot (bool) – Whether or not the client is a bot.

  • banner (bool) – Whether or not to print startup banner.

property servers: list[Server]#

The list of servers the client is in.

await set_status(text: str | None = None, presence: PresenceType | None = None)[source]#

Sets the client’s status.

Parameters:
  • text (Optional[str]) – The text to set the status to.

  • presence (Optional[str]) – The presence to set the status to.

await start(token: str, *, bot: bool = True, banner: bool = True)[source]#

Start the client.

Parameters:
  • token (str) – The bot token.

  • bot (bool) – Whether or not the client is a bot.

  • banner (bool) – Whether or not to print startup banner.

property users: list[User]#

The list of users the client has cached.

await wait_for(event: str, *, timeout: float | None = None, check: Callable[[...], bool] | None = None) Any[source]#

Waits for an event to be triggered.

Note

The event can be anything, be it a message, userupdate or whatever. :trol:

Parameters:
  • event (str) – The event to wait for.

  • timeout (Optional[float]) – The amount of time to wait for the event to be triggered.

  • check (Optional[Callable[..., bool]]) – A function to filter events to a matching predicate, *must* return a boolean for it to work properly.

Raises:

asyncio.TimeoutError – If the event wasn’t triggered within the timeout.

Examples

import voltage

client = voltage.Client()

@client.listen("message")
async def message(message):
    if message.content == "-wait":
        await message.reply("Okay, send something")
        msg = await client.wait_for("message", check=lambda m: m.author == message.author)
        await message.reply("You sent: " + msg.content)

client.run("token")

Abstract Base Classes#

Attributes
Methods
class voltage.Messageable[source]#

A class which all messageable have to inhertit from.

channel_id#

The ID of the messageable object’s channel.

Type:

str

cache#

The cache handler of the messageable object.

Type:

CacheHandler

await end_typing()[source]#

Stop sending a typing indicator to the messageable object’s channel.

await fetch_message(message_id: str) Message[source]#

Fetch a message from the messageable object’s channel.

Parameters:

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

Returns:

The message that got fetched.

Return type:

Message

await get_id() str[source]#

Get the ID of the messageable object’s channel.

Returns:

The ID of the messageable object’s channel.

Return type:

str

await history(limit: int = 100, *, sort: SortType = SortType.latest, before: str | None = None, after: str | None = None, nearby: str | None = None) MessageIterator[source]#

Fetch the messageable object’s channel’s history.

Parameters:
  • limit (Optional[int]) – The limit of the history.

  • sort (Optional[SortType]) – The sort type of the history.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

  • nearby (Optional[str]) – The ID of the message to fetch nearby.

Returns:

The messages that got fetched.

Return type:

List[Message]

await purge(amount: int)[source]#

Purge messages from the messageable object’s channel.

Parameters:

amount (int) – The amount of messages to purge.

await search(query: str, *, sort: SortType = SortType.latest, limit: int = 100, before: str | None = None, after: str | None = None) MessageIterator[source]#

Search for messages in the messageable object’s channel.

Parameters:
  • query (str) – The query to search for.

  • sort (Optional[SortType]) – The sort type of the search.

  • limit (Optional[int]) – The limit of the search.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

Returns:

The messages that got found.

Return type:

List[Message]

await send(content: str | None = None, *, embed: SendableEmbed | SendableEmbedPayload | None = None, embeds: List[SendableEmbed | SendableEmbedPayload] | None = None, attachment: File | str | None = None, attachments: List[File | str] | None = None, reply: MessageReply | None = None, replies: List[MessageReply | MessageReplyPayload] | None = None, masquerade: MessageMasquerade | None = None, interactions: MessageInteractions | None = None, delete_after: float | None = None) Message[source]#

Send a message to the messageable object’s channel.

Parameters:
  • content (Optional[str]) – The content of the message.

  • embed (Optional[Embed]) – The embed of the message.

  • embeds (Optional[List[Embed]]) – The embeds of the message.

  • attachment (Optional[File]) – The attachment of the message.

  • attachments (Optional[List[File]]) – The attachments of the message.

  • reply (Optional[MessageReply]) – The reply of the message.

  • replies (Optional[List[MessageReply]]) – The replies of the message.

  • masquerade (Optional[MessageMasquerade]) – The masquerade of the message.

  • interactions (Optional[MessageInteractions]) – The interactions of the message.

Returns:

The message that got sent.

Return type:

Message

await start_typing()[source]#

Send a typing indicator to the messageable object’s channel.

typing() Typing[source]#

A context manager that sends a typing indicator to the messageable object’s channel.

class voltage.Channel(data: ChannelPayload, cache: CacheHandler, server_id: str | None = None)[source]#

The base class that all channels inherit from.

id#

The ID of the channel.

Type:

str

created_at#

The timestamp of when the channel was created.

Type:

int

type#

The type of the channel.

Type:

ChannelType

server#

The server the channel belongs to.

Type:

Optional[Server]

name#

The name of the channel if it has one.

Type:

Optional[str]

await delete()[source]#

Deletes the channel.

await edit(*, name: str | None = None, description: str | None = NotSupplied, icon: str | File | None = NotSupplied, nsfw: bool | None = None)[source]#

Edits the channel.

Parameters:
  • name (Optional[str]) – The new name of the channel.

  • description (Optional[str]) – The new description of the channel.

  • icon (Optional[str or File]) – The new icon of the channel.

  • nsfw (Optional[bool]) – Whether the channel is NSFW or not.

property jump_url: str#

Returns a URL that allows the client to jump to the channel.

property mention#

Returns a string that allows you to mention the channel.

await set_default_permissions(permissions: Permissions)[source]#

Sets the default permissions for the channel.

Parameters:

permissions (Permissions) – The new default permissions for the channel.

await set_role_permission(role: Role, permissions: Permissions)[source]#

Sets the permissions for a role in the channel.

Parameters:
  • role (Role) – The role to set the permissions for.

  • permissions (Permissions) – The new permissions for the role.

Models#

Servers#

class voltage.Server(data: ServerPayload, cache: CacheHandler)[source]#

A class which represents a Voltage server.

id#

The server’s ID.

Type:

str

created_at#

The timestamp the server was created at.

Type:

int

name#

The server’s name.

Type:

str

description#

The server’s description.

Type:

Optional[str]

owner_id#

The server’s owner’s ID.

Type:

str

owner#

The server’s owner.

Type:

User

nsfw#

Whether the server is NSFW or not.

Type:

bool

system_messages#

The server’s system message configuration.

Type:

Optional[SystemMessages]

icon#

The server’s icon.

Type:

Optional[Asset]

banner#

The server’s banner.

Type:

Optional[Asset]

members#

The server’s members.

Type:

List[Member]

channels#

The server’s channels.

Type:

List[Channel]

roles#

The server’s roles.

Type:

List[Role]

categories#

The server’s categories.

Type:

List[Category]

property categories: List[Category]#

A list of all the categories this server has.

property channels: List[Channel]#

A list of all the channels this server has.

await create_category(name: str, position: int | None = None)[source]#

Creates a category in this server.

Parameters:
  • name (str) – The name of the category to create.

  • position (Optional[int]) – The position of the category to create.

Returns:

The category that was created.

Return type:

Category

await create_channel(name: str, description: str | None = None, nsfw: bool = False, type: Literal['Text', 'Voice'] = 'Text')[source]#

Creates a channel in this server.

Parameters:
  • name (str) – The name of the channel to create.

  • description (Optional[str]) – The description of the channel to create.

  • nsfw (Optional[bool]) – Whether the channel is NSFW or not.

  • type (Optional[Literal]) – The type of channel to create.

Returns:

The channel that was created.

Return type:

Channel

await create_role(name: str)[source]#

Creates a role in this server.

Parameters:

name (str) – The name of the role to create.

Returns:

The role that was created.

Return type:

Role

await fetch_bans()[source]#

Fetches all the bans for this server.

Returns:

A list of all the bans for this server.

Return type:

List[Ban]

await fetch_invites()[source]#

Fetches all the invites for this server.

Returns:

A list of all the invites for this server.

Return type:

List[Invite]

await fetch_member(member_id: str) Member[source]#

Fetches a member from this server.

Parameters:

member_id (str) – The ID of the member to fetch.

Returns:

The member with the given ID.

Return type:

Member

get_category(category_id: str) Category | None[source]#

Gets a category by its ID.

Parameters:

category_id (str) – The ID of the category to get.

Returns:

The category with the given ID, or None if it doesn’t exist.

Return type:

Optional[Category]

get_channel(channel_id: str) Channel | None[source]#

Gets a channel by its ID.

Parameters:

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

Returns:

The channel with the given ID, or None if it doesn’t exist.

Return type:

Optional[Channel]

get_member(member: str) Member | None[source]#

Gets a member by their ID, a mention, their name or nickname.

Parameters:

member (str) – The ID, mention, name or nickname of the member to get.

Returns:

The member with the given ID, or None if it doesn’t exist.

Return type:

Optional[Member]

get_role(role_id: str) Role | None[source]#

Gets a role by its ID.

Parameters:

role_id (str) – The ID of the role to get.

Returns:

The role with the given ID, or None if it doesn’t exist.

Return type:

Optional[Role]

property jump_url: str#

Returns a URL that allows the client to jump to the category.

await leave()[source]#

Leaves the server.

Note

Due to revolt api being weird, if the bot owns the server (somehow), it will delete it instead of leaving.

property members: List[Member]#

A list of all the members this server has.

property owner: User#

The server’s owner.

property roles: List[Role]#

A list of all the roles this server has.

await set_default_permissions(permissions: Permissions)[source]#

Sets the default permissions for the server.

Parameters:

permissions (Permissions) – The role’s new permissions.

Attributes
Methods
class voltage.ServerBan(data: BanPayload, cache: CacheHandler)[source]#

A class which represents a Voltage server ban.

user#

The user who was banned.

Type:

User

server#

The server the user was banned from.

Type:

Server

reason#

The reason for the ban.

Type:

Optional[str]

await unban()[source]#

Unbans the user from the server.

class voltage.SystemMessages(data: SystemMessagesConfigPayload, cache: CacheHandler)[source]#

A class that represents a Voltage server’s system message configuration.

user_joined#

The channel the user joined message is configured to.

Type:

Optional[Channel]

user_left#

The channel the user left message is configured to.

Type:

Optional[Channel]

user_banned#

The channel the user banned message is configured to.

Type:

Optional[Channel]

user_kicked#

The channel the user kicked message is configured to.

Type:

Optional[Channel]

property user_banned: Channel | None#

The channel the user banned message is configured to.

property user_joined: Channel | None#

The channel the user joined message is configured to.

property user_kicked: Channel | None#

The channel the user kicked message is configured to.

property user_left: Channel | None#

The channel the user left message is configured to.

Members#

class voltage.Member(data: MemberPayload, server: Server, cache: CacheHandler)[source]#

A class that represents a Voltage server member.

This class is a subclass of User and inherits all of its attributes.

server#

The server that the member belongs to.

Type:

Server

nickname#

The member’s nickname.

Type:

Optional[str]

server_avatar#

The member’s avatar.

Type:

Optional[Asset]

roles#

The member’s roles.

Type:

List[Role]

permissions#

The member’s permissions.

Type:

Permissions

await add_roles(*roles: Role)[source]#

A method that adds roles to the member.

Parameters:

*roles (Role) – The roles to add to the member.

await ban(reason: str | None = None)[source]#

A method that bans the member from the server.

Parameters:

reason (Optional[str]) – The reason for banning the member.

property display_avatar#

Returns the member’s display avatar.

This is the member’s masquerade avatar or their server’s avatar if they have one, otherwise their avatar.

property display_name#

Returns the member’s display name.

This is the member’s masquerade name or nickname if they have one, otherwise their username.

await end_typing()#

Stop sending a typing indicator to the messageable object’s channel.

await fetch_message(message_id: str) Message#

Fetch a message from the messageable object’s channel.

Parameters:

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

Returns:

The message that got fetched.

Return type:

Message

await fetch_profile() UserProfile#

A method which fetches a user’s profile.

Returns:

The user’s profile.

Return type:

UserProfile

await get_id()#

Get the ID of the messageable object’s channel.

Returns:

The ID of the messageable object’s channel.

Return type:

str

await history(limit: int = 100, *, sort: SortType = SortType.latest, before: str | None = None, after: str | None = None, nearby: str | None = None) MessageIterator#

Fetch the messageable object’s channel’s history.

Parameters:
  • limit (Optional[int]) – The limit of the history.

  • sort (Optional[SortType]) – The sort type of the history.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

  • nearby (Optional[str]) – The ID of the message to fetch nearby.

Returns:

The messages that got fetched.

Return type:

List[Message]

await kick()[source]#

A method that kicks the member from the server.

await purge(amount: int)#

Purge messages from the messageable object’s channel.

Parameters:

amount (int) – The amount of messages to purge.

await remove_avatar()[source]#

A method that removes the member’s avatar.

await search(query: str, *, sort: SortType = SortType.latest, limit: int = 100, before: str | None = None, after: str | None = None) MessageIterator#

Search for messages in the messageable object’s channel.

Parameters:
  • query (str) – The query to search for.

  • sort (Optional[SortType]) – The sort type of the search.

  • limit (Optional[int]) – The limit of the search.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

Returns:

The messages that got found.

Return type:

List[Message]

await send(content: str | None = None, *, embed: SendableEmbed | SendableEmbedPayload | None = None, embeds: List[SendableEmbed | SendableEmbedPayload] | None = None, attachment: File | str | None = None, attachments: List[File | str] | None = None, reply: MessageReply | None = None, replies: List[MessageReply | MessageReplyPayload] | None = None, masquerade: MessageMasquerade | None = None, interactions: MessageInteractions | None = None, delete_after: float | None = None) Message#

Send a message to the messageable object’s channel.

Parameters:
  • content (Optional[str]) – The content of the message.

  • embed (Optional[Embed]) – The embed of the message.

  • embeds (Optional[List[Embed]]) – The embeds of the message.

  • attachment (Optional[File]) – The attachment of the message.

  • attachments (Optional[List[File]]) – The attachments of the message.

  • reply (Optional[MessageReply]) – The reply of the message.

  • replies (Optional[List[MessageReply]]) – The replies of the message.

  • masquerade (Optional[MessageMasquerade]) – The masquerade of the message.

  • interactions (Optional[MessageInteractions]) – The interactions of the message.

Returns:

The message that got sent.

Return type:

Message

set_masquerade(name: str | None, avatar: PartialAsset | None)#

A method which sets a user’s masquerade.

Parameters:
  • name (str) – The masquerade name.

  • avatar (PartialAsset) – The masquerade avatar.

await set_nickname(nickname: str | None)[source]#

A method that sets the member’s nickname.

Parameters:

nickname (Optional[str]) – The nickname to set.

await start_typing()#

Send a typing indicator to the messageable object’s channel.

typing() Typing#

A context manager that sends a typing indicator to the messageable object’s channel.

await unban()[source]#

A method that unbans the member from the server.

Categories#

class voltage.Category(data: CategoryPayload, cache: CacheHandler)[source]#

A class that represents a Voltage category.

id#

The category’s ID.

Type:

str

name#

The name of the category.

Type:

str

description#

The name of the category.

Type:

Optional[str]

channels#

A list of all channels in the category.

Type:

List[Channel]

Channels#

Attributes
Methods
class voltage.SavedMessageChannel(data: SavedMessagePayload, cache: CacheHandler)[source]#

The class representing the Voltage saved messages channel.

await delete()#

Deletes the channel.

await edit()[source]#

Edits the channel.

Parameters:
  • name (Optional[str]) – The new name of the channel.

  • description (Optional[str]) – The new description of the channel.

  • icon (Optional[str or File]) – The new icon of the channel.

  • nsfw (Optional[bool]) – Whether the channel is NSFW or not.

await end_typing()#

Stop sending a typing indicator to the messageable object’s channel.

await fetch_message(message_id: str) Message#

Fetch a message from the messageable object’s channel.

Parameters:

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

Returns:

The message that got fetched.

Return type:

Message

await get_id()#

Get the ID of the messageable object’s channel.

Returns:

The ID of the messageable object’s channel.

Return type:

str

await history(limit: int = 100, *, sort: SortType = SortType.latest, before: str | None = None, after: str | None = None, nearby: str | None = None) MessageIterator#

Fetch the messageable object’s channel’s history.

Parameters:
  • limit (Optional[int]) – The limit of the history.

  • sort (Optional[SortType]) – The sort type of the history.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

  • nearby (Optional[str]) – The ID of the message to fetch nearby.

Returns:

The messages that got fetched.

Return type:

List[Message]

property jump_url: str#

Returns a URL that allows the client to jump to the channel.

property mention#

Returns a string that allows you to mention the channel.

await purge(amount: int)#

Purge messages from the messageable object’s channel.

Parameters:

amount (int) – The amount of messages to purge.

await search(query: str, *, sort: SortType = SortType.latest, limit: int = 100, before: str | None = None, after: str | None = None) MessageIterator#

Search for messages in the messageable object’s channel.

Parameters:
  • query (str) – The query to search for.

  • sort (Optional[SortType]) – The sort type of the search.

  • limit (Optional[int]) – The limit of the search.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

Returns:

The messages that got found.

Return type:

List[Message]

await send(content: str | None = None, *, embed: SendableEmbed | SendableEmbedPayload | None = None, embeds: List[SendableEmbed | SendableEmbedPayload] | None = None, attachment: File | str | None = None, attachments: List[File | str] | None = None, reply: MessageReply | None = None, replies: List[MessageReply | MessageReplyPayload] | None = None, masquerade: MessageMasquerade | None = None, interactions: MessageInteractions | None = None, delete_after: float | None = None) Message#

Send a message to the messageable object’s channel.

Parameters:
  • content (Optional[str]) – The content of the message.

  • embed (Optional[Embed]) – The embed of the message.

  • embeds (Optional[List[Embed]]) – The embeds of the message.

  • attachment (Optional[File]) – The attachment of the message.

  • attachments (Optional[List[File]]) – The attachments of the message.

  • reply (Optional[MessageReply]) – The reply of the message.

  • replies (Optional[List[MessageReply]]) – The replies of the message.

  • masquerade (Optional[MessageMasquerade]) – The masquerade of the message.

  • interactions (Optional[MessageInteractions]) – The interactions of the message.

Returns:

The message that got sent.

Return type:

Message

await set_default_permissions()[source]#

Sets the default permissions for the channel.

Parameters:

permissions (Permissions) – The new default permissions for the channel.

await set_role_permission()[source]#

Sets the permissions for a role in the channel.

Parameters:
  • role (Role) – The role to set the permissions for.

  • permissions (Permissions) – The new permissions for the role.

await start_typing()#

Send a typing indicator to the messageable object’s channel.

typing() Typing#

A context manager that sends a typing indicator to the messageable object’s channel.

Attributes
Methods
class voltage.DMChannel(data: DMChannelPayload, cache: CacheHandler)[source]#

The class representing the Voltage direct messages channel.

await delete()#

Deletes the channel.

await edit()[source]#

Edits the channel.

Parameters:
  • name (Optional[str]) – The new name of the channel.

  • description (Optional[str]) – The new description of the channel.

  • icon (Optional[str or File]) – The new icon of the channel.

  • nsfw (Optional[bool]) – Whether the channel is NSFW or not.

await end_typing()#

Stop sending a typing indicator to the messageable object’s channel.

await fetch_message(message_id: str) Message#

Fetch a message from the messageable object’s channel.

Parameters:

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

Returns:

The message that got fetched.

Return type:

Message

await get_id()#

Get the ID of the messageable object’s channel.

Returns:

The ID of the messageable object’s channel.

Return type:

str

await history(limit: int = 100, *, sort: SortType = SortType.latest, before: str | None = None, after: str | None = None, nearby: str | None = None) MessageIterator#

Fetch the messageable object’s channel’s history.

Parameters:
  • limit (Optional[int]) – The limit of the history.

  • sort (Optional[SortType]) – The sort type of the history.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

  • nearby (Optional[str]) – The ID of the message to fetch nearby.

Returns:

The messages that got fetched.

Return type:

List[Message]

property jump_url: str#

Returns a URL that allows the client to jump to the channel.

property mention#

Returns a string that allows you to mention the channel.

await purge(amount: int)#

Purge messages from the messageable object’s channel.

Parameters:

amount (int) – The amount of messages to purge.

await search(query: str, *, sort: SortType = SortType.latest, limit: int = 100, before: str | None = None, after: str | None = None) MessageIterator#

Search for messages in the messageable object’s channel.

Parameters:
  • query (str) – The query to search for.

  • sort (Optional[SortType]) – The sort type of the search.

  • limit (Optional[int]) – The limit of the search.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

Returns:

The messages that got found.

Return type:

List[Message]

await send(content: str | None = None, *, embed: SendableEmbed | SendableEmbedPayload | None = None, embeds: List[SendableEmbed | SendableEmbedPayload] | None = None, attachment: File | str | None = None, attachments: List[File | str] | None = None, reply: MessageReply | None = None, replies: List[MessageReply | MessageReplyPayload] | None = None, masquerade: MessageMasquerade | None = None, interactions: MessageInteractions | None = None, delete_after: float | None = None) Message#

Send a message to the messageable object’s channel.

Parameters:
  • content (Optional[str]) – The content of the message.

  • embed (Optional[Embed]) – The embed of the message.

  • embeds (Optional[List[Embed]]) – The embeds of the message.

  • attachment (Optional[File]) – The attachment of the message.

  • attachments (Optional[List[File]]) – The attachments of the message.

  • reply (Optional[MessageReply]) – The reply of the message.

  • replies (Optional[List[MessageReply]]) – The replies of the message.

  • masquerade (Optional[MessageMasquerade]) – The masquerade of the message.

  • interactions (Optional[MessageInteractions]) – The interactions of the message.

Returns:

The message that got sent.

Return type:

Message

await set_default_permissions()[source]#

Sets the default permissions for the channel.

Parameters:

permissions (Permissions) – The new default permissions for the channel.

await set_role_permission()[source]#

Sets the permissions for a role in the channel.

Parameters:
  • role (Role) – The role to set the permissions for.

  • permissions (Permissions) – The new permissions for the role.

await start_typing()#

Send a typing indicator to the messageable object’s channel.

typing() Typing#

A context manager that sends a typing indicator to the messageable object’s channel.

class voltage.GroupDMChannel(data: GroupDMChannelPayload, cache: CacheHandler)[source]#

The class representing the Voltage group direct messages channel.

name#

The name of the group direct messages channel.

Type:

str

description#

The description of the group direct messages channel.

Type:

Optional[str]

nsfw#

Whether the channel is NSFW or not.

Type:

bool

owner#

The owner of the group direct messages channel.

Type:

User

recipients#

The recipients of the group direct messages channel.

Type:

List[User]

icon#

The icon of the group direct messages channel.

Type:

Optional[Asset]

permissions#

The permissions of the group direct messages channel.

Type:

Permissions

add_recepient(user: User)[source]#

Adds a user to the group direct messages channel.

Parameters:

user (User) – The user to add to the group direct messages channel.

await delete()#

Deletes the channel.

await edit(*, name: str | None = None, description: str | None = NotSupplied, icon: str | File | None = NotSupplied, nsfw: bool | None = None)#

Edits the channel.

Parameters:
  • name (Optional[str]) – The new name of the channel.

  • description (Optional[str]) – The new description of the channel.

  • icon (Optional[str or File]) – The new icon of the channel.

  • nsfw (Optional[bool]) – Whether the channel is NSFW or not.

await end_typing()#

Stop sending a typing indicator to the messageable object’s channel.

await fetch_message(message_id: str) Message#

Fetch a message from the messageable object’s channel.

Parameters:

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

Returns:

The message that got fetched.

Return type:

Message

await get_id()#

Get the ID of the messageable object’s channel.

Returns:

The ID of the messageable object’s channel.

Return type:

str

await history(limit: int = 100, *, sort: SortType = SortType.latest, before: str | None = None, after: str | None = None, nearby: str | None = None) MessageIterator#

Fetch the messageable object’s channel’s history.

Parameters:
  • limit (Optional[int]) – The limit of the history.

  • sort (Optional[SortType]) – The sort type of the history.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

  • nearby (Optional[str]) – The ID of the message to fetch nearby.

Returns:

The messages that got fetched.

Return type:

List[Message]

property jump_url: str#

Returns a URL that allows the client to jump to the channel.

property mention#

Returns a string that allows you to mention the channel.

await purge(amount: int)#

Purge messages from the messageable object’s channel.

Parameters:

amount (int) – The amount of messages to purge.

remove_recepient(user: User)[source]#

Removes a user from the group direct messages channel.

Parameters:

user (User) – The user to remove from the group direct messages channel.

await search(query: str, *, sort: SortType = SortType.latest, limit: int = 100, before: str | None = None, after: str | None = None) MessageIterator#

Search for messages in the messageable object’s channel.

Parameters:
  • query (str) – The query to search for.

  • sort (Optional[SortType]) – The sort type of the search.

  • limit (Optional[int]) – The limit of the search.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

Returns:

The messages that got found.

Return type:

List[Message]

await send(content: str | None = None, *, embed: SendableEmbed | SendableEmbedPayload | None = None, embeds: List[SendableEmbed | SendableEmbedPayload] | None = None, attachment: File | str | None = None, attachments: List[File | str] | None = None, reply: MessageReply | None = None, replies: List[MessageReply | MessageReplyPayload] | None = None, masquerade: MessageMasquerade | None = None, interactions: MessageInteractions | None = None, delete_after: float | None = None) Message#

Send a message to the messageable object’s channel.

Parameters:
  • content (Optional[str]) – The content of the message.

  • embed (Optional[Embed]) – The embed of the message.

  • embeds (Optional[List[Embed]]) – The embeds of the message.

  • attachment (Optional[File]) – The attachment of the message.

  • attachments (Optional[List[File]]) – The attachments of the message.

  • reply (Optional[MessageReply]) – The reply of the message.

  • replies (Optional[List[MessageReply]]) – The replies of the message.

  • masquerade (Optional[MessageMasquerade]) – The masquerade of the message.

  • interactions (Optional[MessageInteractions]) – The interactions of the message.

Returns:

The message that got sent.

Return type:

Message

await set_default_permissions(permissions: Permissions)#

Sets the default permissions for the channel.

Parameters:

permissions (Permissions) – The new default permissions for the channel.

await set_role_permission()[source]#

Sets the permissions for a role in the channel.

Parameters:
  • role (Role) – The role to set the permissions for.

  • permissions (Permissions) – The new permissions for the role.

await start_typing()#

Send a typing indicator to the messageable object’s channel.

typing() Typing#

A context manager that sends a typing indicator to the messageable object’s channel.

class voltage.TextChannel(data: TextChannelPayload, cache: CacheHandler, server_id: str | None = None)[source]#

The class representing the Voltage text channels.

name#

The name of the text channel.

Type:

str

description#

The description of the text channel.

Type:

Optional[str]

last_message#

The last message sent in the text channel.

Type:

Optional[Message]

nsfw#

Whether the text channel is NSFW or not.

Type:

bool

default_permissions#

The default permissions for the text channel.

Type:

Permissions

role_permissions#

A role-id permission pair dict representing the role-specific permissions for the text channel.

Type:

Dict[str, Permissions]

icon#

The icon of the text channel.

Type:

Optional[Asset]

await delete()#

Deletes the channel.

await edit(*, name: str | None = None, description: str | None = NotSupplied, icon: str | File | None = NotSupplied, nsfw: bool | None = None)#

Edits the channel.

Parameters:
  • name (Optional[str]) – The new name of the channel.

  • description (Optional[str]) – The new description of the channel.

  • icon (Optional[str or File]) – The new icon of the channel.

  • nsfw (Optional[bool]) – Whether the channel is NSFW or not.

await end_typing()#

Stop sending a typing indicator to the messageable object’s channel.

await fetch_message(message_id: str) Message#

Fetch a message from the messageable object’s channel.

Parameters:

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

Returns:

The message that got fetched.

Return type:

Message

await get_id()#

Get the ID of the messageable object’s channel.

Returns:

The ID of the messageable object’s channel.

Return type:

str

await history(limit: int = 100, *, sort: SortType = SortType.latest, before: str | None = None, after: str | None = None, nearby: str | None = None) MessageIterator#

Fetch the messageable object’s channel’s history.

Parameters:
  • limit (Optional[int]) – The limit of the history.

  • sort (Optional[SortType]) – The sort type of the history.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

  • nearby (Optional[str]) – The ID of the message to fetch nearby.

Returns:

The messages that got fetched.

Return type:

List[Message]

property jump_url: str#

Returns a URL that allows the client to jump to the channel.

property mention#

Returns a string that allows you to mention the channel.

await purge(amount: int)#

Purge messages from the messageable object’s channel.

Parameters:

amount (int) – The amount of messages to purge.

await search(query: str, *, sort: SortType = SortType.latest, limit: int = 100, before: str | None = None, after: str | None = None) MessageIterator#

Search for messages in the messageable object’s channel.

Parameters:
  • query (str) – The query to search for.

  • sort (Optional[SortType]) – The sort type of the search.

  • limit (Optional[int]) – The limit of the search.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

Returns:

The messages that got found.

Return type:

List[Message]

await send(content: str | None = None, *, embed: SendableEmbed | SendableEmbedPayload | None = None, embeds: List[SendableEmbed | SendableEmbedPayload] | None = None, attachment: File | str | None = None, attachments: List[File | str] | None = None, reply: MessageReply | None = None, replies: List[MessageReply | MessageReplyPayload] | None = None, masquerade: MessageMasquerade | None = None, interactions: MessageInteractions | None = None, delete_after: float | None = None) Message#

Send a message to the messageable object’s channel.

Parameters:
  • content (Optional[str]) – The content of the message.

  • embed (Optional[Embed]) – The embed of the message.

  • embeds (Optional[List[Embed]]) – The embeds of the message.

  • attachment (Optional[File]) – The attachment of the message.

  • attachments (Optional[List[File]]) – The attachments of the message.

  • reply (Optional[MessageReply]) – The reply of the message.

  • replies (Optional[List[MessageReply]]) – The replies of the message.

  • masquerade (Optional[MessageMasquerade]) – The masquerade of the message.

  • interactions (Optional[MessageInteractions]) – The interactions of the message.

Returns:

The message that got sent.

Return type:

Message

await set_default_permissions(permissions: Permissions)#

Sets the default permissions for the channel.

Parameters:

permissions (Permissions) – The new default permissions for the channel.

await set_role_permission(role: Role, permissions: Permissions)#

Sets the permissions for a role in the channel.

Parameters:
  • role (Role) – The role to set the permissions for.

  • permissions (Permissions) – The new permissions for the role.

await start_typing()#

Send a typing indicator to the messageable object’s channel.

typing() Typing#

A context manager that sends a typing indicator to the messageable object’s channel.

class voltage.VoiceChannel(data: VoiceChannelPayload, cache: CacheHandler, server_id: str | None = None)[source]#

The class representing the Voltage voice channels.

name#

The name of the voice channel.

Type:

str

description#

The description of the voice channel.

Type:

Optional[str]

default_permissions#

The default permissions for the voice channel.

Type:

Permissions

role_permissions#

A role-id permission pair dict representing the role-specific permissions for the voice channel.

Type:

Dict[str, Permissions]

icon#

The icon of the voice channel.

Type:

Optional[Asset]

await delete()#

Deletes the channel.

await edit(*, name: str | None = None, description: str | None = NotSupplied, icon: str | File | None = NotSupplied, nsfw: bool | None = None)#

Edits the channel.

Parameters:
  • name (Optional[str]) – The new name of the channel.

  • description (Optional[str]) – The new description of the channel.

  • icon (Optional[str or File]) – The new icon of the channel.

  • nsfw (Optional[bool]) – Whether the channel is NSFW or not.

property jump_url: str#

Returns a URL that allows the client to jump to the channel.

property mention#

Returns a string that allows you to mention the channel.

await set_default_permissions(permissions: Permissions)#

Sets the default permissions for the channel.

Parameters:

permissions (Permissions) – The new default permissions for the channel.

await set_role_permission(role: Role, permissions: Permissions)#

Sets the permissions for a role in the channel.

Parameters:
  • role (Role) – The role to set the permissions for.

  • permissions (Permissions) – The new permissions for the role.

Messages#

class voltage.Message(data: MessagePayload, cache: CacheHandler)[source]#

A class that represents a Voltage message.

id#

The id of the message.

Type:

Optional[str]

created_at#

The timestamp of when the message was created.

Type:

int

channel#

The channel the message was sent in.

Type:

Channel

attachments#

The attachments of the message.

Type:

List[Asset]]

embeds#

The embeds of the message.

Type:

List[Embed]

content#

The content of the message.

Type:

str

author#

The author of the message.

Type:

Union[User, Member]

replies#

The replies of the message.

Type:

List[Message]

mentions#

A list of mentioned users/members.

Type:

List[Union[User, Member]]

await delete(*, delay: float | None = None)[source]#

Deletes the message.

await edit(content: str | None = None, *, embed: SendableEmbedPayload | SendableEmbed | None = None, embeds: List[SendableEmbedPayload | SendableEmbed] | None = None)[source]#

Edits the message.

Parameters:
  • content (Optional[str]) – The new content of the message.

  • embed (Optional[SendableEmbed]) – The new embed of the message.

  • embeds (Optional[List[SendableEmbed]]) – The new embeds of the message.

await full_replies()[source]#

Returns the full list of replies of the message.

property jump_url: str#

Returns a URL that allows the client to jump to the message.

await reply(content: str | None = None, *, embed: SendableEmbed | SendableEmbedPayload | None = None, embeds: List[SendableEmbed | SendableEmbedPayload] | None = None, attachment: File | str | None = None, attachments: List[File | str] | None = None, masquerade: MessageMasquerade | None = None, interactions: MessageInteractions | None = None, mention: bool = True, delete_after: float | None = None) Message[source]#

Replies to the message.

Parameters:
  • content (Optional[str]) – The content of the message.

  • embed (Optional[Embed]) – The embed of the message.

  • embeds (Optional[List[Embed]]) – The embeds of the message.

  • attachment (Optional[File]) – The attachment of the message.

  • attachments (Optional[List[File]]) – The attachments of the message.

  • masquerade (Optional[MessageMasquerade]) – The masquerade of the message.

  • interactions (Optional[MessageInteractions]) – The interactions of the message.

  • mention (Optional[bool]) – Wether or not the reply mentions the author of the message.

  • delete_after (Optional[float]) – The amount of seconds to wait before deleting the message, if None the message will not be deleted.

Returns:

The message that got sent.

Return type:

Message

Attributes
Methods
class voltage.MessageReply(message: Message, mention: bool)[source]#

A named tuple that represents a message reply.

message#

The message that was replied to,

Type:

Message

mention#

Wether or not the reply mentions the author of the message.

Type:

bool

count(value, /)#

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

mention: bool#

Alias for field number 1

message: Message#

Alias for field number 0

to_dict() MessageReplyPayload[source]#

Returns a dictionary representation of the message reply.

Methods
class voltage.MessageMasquerade(name: str | None = None, avatar: str | None = None, colour: str | None = None, color: str | None = None)[source]#

A named tuple that represents a message’s masquerade.

name#

The name of the masquerade.

Type:

Optional[str]

avatar#

The url to the masquerade avatar.

Type:

Optional[str]

colour#

CSS-compatible colour of the username.

Type:

Optional[str]

color#

CSS-compatible color of the username.

Type:

Optional[str]

avatar: str | None#

Alias for field number 1

color: str | None#

Alias for field number 3

colour: str | None#

Alias for field number 2

count(value, /)#

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

name: str | None#

Alias for field number 0

to_dict() dict[source]#

Returns a dictionary representation of the message masquerade.

Roles#

class voltage.Role(data: RolePayload, id: str, server: Server, http: HTTPHandler)[source]#

A class that represents a Voltage role.

id#

The role’s ID.

Type:

str

created_at#

The timestamp of when the role was created.

Type:
class:int:

name#

The role’s name.

Type:

str

colour#

The role’s colour.

Type:

str

color#

Alias for colour.

Type:

str

hoist#

Whether the role is hoisted.

Type:

bool

rank#

The role’s position in the role hierarchy.

Type:

int

permissions#

The role’s permissions..

Type:

Permissions

server#

The server the role belongs to.

Type:

Server

server_id#

The ID of the server the role belongs to.

Type:

str

await delete()[source]#

Deletes the role.

await edit(*, name: str | None = None, colour: str | None = NotSupplied, color: str | None = NotSupplied, hoist: bool | None = None, rank: int | None = None)[source]#

Edits the role.

Parameters:
  • name (Optional[str]) – The new name of the role.

  • colour (Optional[str]) – The new colour of the role.

  • color (Optional[str]) – Alias for colour.

  • hoist (Optional[bool]) – Whether the role is hoisted.

  • rank (Optional[int]) – The new rank of the role.

await set_permissions(permissions: Permissions)[source]#

Sets the role’s permissions.

Parameters:

permissions (Optional[Permissions]) – The new server permissions.

Permissions#

Attributes
class voltage.Permissions(flags: OverrideFieldPayload | int)[source]#

A class which represents a member’s permissions.

classmethod from_flags(allow: PermissionsFlags, deny: PermissionsFlags) Permissions[source]#

Creates a Permissions object from two PermissionsFlags.

Also note PermissionsFlags.none()

allow#

The allowed permissions.

Type:

PermissionsFlags

deny#

The denied permissions.

Type:

PermissionsFlags

to_dict() OverrideFieldPayload[source]#

Turns a permission object to a dictionary for api sending purposes.

Invites#

class voltage.Invite(data: InvitePayload, code: str, cache: CacheHandler)[source]#

A class which represents a Voltage invite.

code#

The invite code.

Type:

str

type#

The invite type.

Type:

str

server_id#

The server ID.

Type:

str

server#

The server the invite is for.

Type:

Server

channel_id#

The channel ID.

Type:

str

channel#

The channel the invite is for.

Type:

Channel

member_count#

The member count.

Type:

int

author_name#

The author name.

Type:

str

user#

The user who created the invite.

Type:

User

avatar#

The avatar of the user who created the invite.

Type:

Asset

staticmethod from_partial(code: str, data: PartialInvitePayload, cache: CacheHandler) Invite[source]#

A utility function that creates an Invite object from a partial payload.

Parameters:
  • code (str) – The invite code.

  • data (PartialInvitePayload) – The partial payload.

  • cache (CacheHandler) – The cache handler.

property url: str#

Returns the invite URL.

Files#

Methods
class voltage.File(f: str | bytes, *, filename: str | None = None, spoiler: bool | None = False)[source]#

The Object representing a generic file that can be sent in a Message.

Parameters:
  • f (Union[str, bytes]) – The file to send, can either be a local filename (str) or bytes.

  • filename (Optional[str]) – The name of the file.

  • spoiler (Optional[bool]) – Whether or not the file is a spoiler.

Examples

f = voltage.File("image.png", filename="interesting file", spoiler=True)

await channel.send("Obligatory Message Content", attachment=f) # Uploads the file to autumn, gets the id and sends it.

# You can also send files in embeds.

embed = voltage.SendableEmbed(media=f)
await channel.send("Obligatory Message Content", embed=embed)
await get_id(http: HTTPHandler) str[source]#

Uploads a file to autumn then returns its id for sending. You won’t need to run this method yourself.

Parameters:

http (HTTPHandler) – The http handler.

Returns:

The autumn id of the file.

Return type:

str

Assets#

class voltage.Asset(data: FilePayload, http: HTTPHandler)[source]#

A class that represents a revolt asset.

id#

The id of the asset.

Type:

str

tag#

The tag of the asset.

Type:

str

size#

The size of the asset.

Type:

int

name#

The name of the asset.

Type:

str

width#

The width of the asset.

Type:

Optional[int]

height#

The height of the asset.

Type:

Optional[int]

type#

The type of the asset.

Type:

Optional[AssetType]

content_type#

The content type of the asset.

Type:

str

url#

The url of the asset.

Type:

str

await get_binary() bytes[source]#

Gets the binary data of the asset.

Returns:

The binary data of the asset.

Return type:

bytes

Methods
class voltage.PartialAsset(url: str, http: HTTPHandler)[source]#

A partial asset caused by data lack.

url#

The url of the asset.

Type:

str

id#

The id of the asset.

Type:

str

created_at#

The timestamp of when the asset was created.

Type:

int

tag#

The tag of the asset.

Type:

Optional[str]

size#

The size of the asset.

Type:

int

name#

The name of the asset.

Type:

str

width#

The width of the asset.

Type:

Optional[int]

height#

The height of the asset.

Type:

Optional[int]

type#

The type of the asset.

Type:

Optional[AssetType]

await get_binary() bytes#

Gets the binary data of the asset.

Returns:

The binary data of the asset.

Return type:

bytes

Users#

class voltage.User(data: UserPayload, cache: CacheHandler)[source]#

A class that represents a Voltage user.

id#

The user’s ID.

Type:

str

created_at#

The epoch time when the user was created.

Type:

int

name#

The user’s name.

Type:

str

discriminator#

The user’s discriminator.

Type:

str

avatar#

The user’s avatar.

Type:

Asset

badges#

The user’s badges.

Type:

UserFlags

online#

Whether the user is online or not.

Type:

bool

status#

The user’s status.

Type:

Status

relationships#

The user’s relationships.

Type:

list of Relationship

profile#

The user’s profile.

Type:

UserProfile

bot#

Whether the user is a bot or not.

Type:

bool

owner#

The bot’s owner.

Type:

User

await end_typing()#

Stop sending a typing indicator to the messageable object’s channel.

await fetch_message(message_id: str) Message#

Fetch a message from the messageable object’s channel.

Parameters:

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

Returns:

The message that got fetched.

Return type:

Message

await fetch_profile() UserProfile[source]#

A method which fetches a user’s profile.

Returns:

The user’s profile.

Return type:

UserProfile

await get_id()[source]#

Get the ID of the messageable object’s channel.

Returns:

The ID of the messageable object’s channel.

Return type:

str

await history(limit: int = 100, *, sort: SortType = SortType.latest, before: str | None = None, after: str | None = None, nearby: str | None = None) MessageIterator#

Fetch the messageable object’s channel’s history.

Parameters:
  • limit (Optional[int]) – The limit of the history.

  • sort (Optional[SortType]) – The sort type of the history.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

  • nearby (Optional[str]) – The ID of the message to fetch nearby.

Returns:

The messages that got fetched.

Return type:

List[Message]

await purge(amount: int)#

Purge messages from the messageable object’s channel.

Parameters:

amount (int) – The amount of messages to purge.

await search(query: str, *, sort: SortType = SortType.latest, limit: int = 100, before: str | None = None, after: str | None = None) MessageIterator#

Search for messages in the messageable object’s channel.

Parameters:
  • query (str) – The query to search for.

  • sort (Optional[SortType]) – The sort type of the search.

  • limit (Optional[int]) – The limit of the search.

  • before (Optional[str]) – The ID of the message to fetch before.

  • after (Optional[str]) – The ID of the message to fetch after.

Returns:

The messages that got found.

Return type:

List[Message]

await send(content: str | None = None, *, embed: SendableEmbed | SendableEmbedPayload | None = None, embeds: List[SendableEmbed | SendableEmbedPayload] | None = None, attachment: File | str | None = None, attachments: List[File | str] | None = None, reply: MessageReply | None = None, replies: List[MessageReply | MessageReplyPayload] | None = None, masquerade: MessageMasquerade | None = None, interactions: MessageInteractions | None = None, delete_after: float | None = None) Message#

Send a message to the messageable object’s channel.

Parameters:
  • content (Optional[str]) – The content of the message.

  • embed (Optional[Embed]) – The embed of the message.

  • embeds (Optional[List[Embed]]) – The embeds of the message.

  • attachment (Optional[File]) – The attachment of the message.

  • attachments (Optional[List[File]]) – The attachments of the message.

  • reply (Optional[MessageReply]) – The reply of the message.

  • replies (Optional[List[MessageReply]]) – The replies of the message.

  • masquerade (Optional[MessageMasquerade]) – The masquerade of the message.

  • interactions (Optional[MessageInteractions]) – The interactions of the message.

Returns:

The message that got sent.

Return type:

Message

set_masquerade(name: str | None, avatar: PartialAsset | None)[source]#

A method which sets a user’s masquerade.

Parameters:
  • name (str) – The masquerade name.

  • avatar (PartialAsset) – The masquerade avatar.

await start_typing()#

Send a typing indicator to the messageable object’s channel.

typing() Typing#

A context manager that sends a typing indicator to the messageable object’s channel.

Enums#

class voltage.EmbedType(value)[source]#

An enum which represents an Embed’s type.

class voltage.SortType(value)[source]#

An enum which represents the sort type for fetching messages.

class voltage.ChannelType(value)[source]#

An enum which represents the channel type.

class voltage.AssetType(value)[source]#

An enum which represents the type of an asset.

class voltage.PresenceType(value)[source]#

An enum which represents the type of a presence.

class voltage.RelationshipType(value)[source]#

An enum which represents the type of a relationship between two users.