API Reference#
Client#
- deferror
- defget_channel
- defget_server
- defget_user
- deflisten
- defrun
- asyncset_status
- asyncstart
- asyncwait_for
- class voltage.Client(*, cache_message_limit: int = 5000)[source]#
Base voltage client.
- cache_message_limit#
The maximum amount of messages to cache.
- Type:
int
- 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")
- 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.
- 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.
- 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#
- asyncend_typing
- asyncfetch_message
- asyncget_id
- asynchistory
- asyncpurge
- asyncsearch
- asyncsend
- asyncstart_typing
- deftyping
- 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 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:
- 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:
- asyncdelete
- asyncedit
- asyncset_default_permissions
- asyncset_role_permission
- 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:
- name#
The name of the channel if it has one.
- Type:
Optional[
str
]
- 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
orFile
]) – 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#
- asynccreate_category
- asynccreate_channel
- asynccreate_role
- asyncfetch_bans
- asyncfetch_invites
- asyncfetch_member
- defget_category
- defget_channel
- defget_member
- defget_role
- asyncleave
- asyncset_default_permissions
- 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
- nsfw#
Whether the server is NSFW or not.
- Type:
bool
- system_messages#
The server’s system message configuration.
- Type:
Optional[
SystemMessages
]
- 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:
- 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:
- 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:
- 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:
- 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.
- await set_default_permissions(permissions: Permissions)[source]#
Sets the default permissions for the server.
- Parameters:
permissions (
Permissions
) – The role’s new permissions.
- class voltage.ServerBan(data: BanPayload, cache: CacheHandler)[source]#
A class which represents a Voltage server ban.
- reason#
The reason for the ban.
- Type:
Optional[
str
]
Members#
- asyncadd_roles
- asyncban
- asyncend_typing
- asyncfetch_message
- asyncfetch_profile
- asyncget_id
- asynchistory
- asynckick
- asyncpurge
- asyncremove_avatar
- asyncsearch
- asyncsend
- defset_masquerade
- asyncset_nickname
- asyncstart_typing
- deftyping
- asyncunban
- 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.- nickname#
The member’s nickname.
- Type:
Optional[
str
]
- permissions#
The member’s permissions.
- Type:
- 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:
- 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 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:
- 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.
Categories#
Channels#
- asyncdelete
- asyncedit
- asyncend_typing
- asyncfetch_message
- asyncget_id
- asynchistory
- asyncpurge
- asyncsearch
- asyncsend
- asyncset_default_permissions
- asyncset_role_permission
- asyncstart_typing
- deftyping
- 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
orFile
]) – 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:
- 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:
- 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.
- asyncdelete
- asyncedit
- asyncend_typing
- asyncfetch_message
- asyncget_id
- asynchistory
- asyncpurge
- asyncsearch
- asyncsend
- asyncset_default_permissions
- asyncset_role_permission
- asyncstart_typing
- deftyping
- 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
orFile
]) – 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:
- 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:
- 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.
- defadd_recepient
- asyncdelete
- asyncedit
- asyncend_typing
- asyncfetch_message
- asyncget_id
- asynchistory
- asyncpurge
- defremove_recepient
- asyncsearch
- asyncsend
- asyncset_default_permissions
- asyncset_role_permission
- asyncstart_typing
- deftyping
- 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
- permissions#
The permissions of the group direct messages channel.
- Type:
- 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
orFile
]) – 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:
- 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:
- 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.
- asyncdelete
- asyncedit
- asyncend_typing
- asyncfetch_message
- asyncget_id
- asynchistory
- asyncpurge
- asyncsearch
- asyncsend
- asyncset_default_permissions
- asyncset_role_permission
- asyncstart_typing
- deftyping
- 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
]
- nsfw#
Whether the text channel is NSFW or not.
- Type:
bool
- default_permissions#
The default permissions for the text channel.
- Type:
- role_permissions#
A role-id permission pair dict representing the role-specific permissions for the text channel.
- Type:
Dict[
str
,Permissions
]
- 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
orFile
]) – 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:
- 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:
- 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.
- asyncdelete
- asyncedit
- asyncset_default_permissions
- asyncset_role_permission
- 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:
- role_permissions#
A role-id permission pair dict representing the role-specific permissions for the voice channel.
- Type:
Dict[
str
,Permissions
]
- 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
orFile
]) – 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#
- asyncdelete
- asyncedit
- asyncfull_replies
- asyncreply
- 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
- embeds#
The embeds of the message.
- Type:
List[
Embed
]
- content#
The content of the message.
- Type:
str
- 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.
- 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, ifNone
the message will not be deleted.
- Returns:
The message that got sent.
- Return type:
- class voltage.MessageReply(message: Message, mention: bool)[source]#
A named tuple that represents a message reply.
- 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
- 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
Roles#
- asyncdelete
- asyncedit
- asyncset_permissions
- 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
- 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:
- server_id#
The ID of the server the role belongs to.
- Type:
str
- 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 forcolour
.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#
- 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
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
- channel_id#
The channel ID.
- Type:
str
- member_count#
The member count.
- Type:
int
- author_name#
The author name.
- Type:
str
- 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#
- asyncget_id
- 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)
Assets#
- asyncget_binary
- 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
]
- content_type#
The content type of the asset.
- Type:
str
- url#
The url of the asset.
- Type:
str
- asyncget_binary
- 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
]
- await get_binary() bytes #
Gets the binary data of the asset.
- Returns:
The binary data of the asset.
- Return type:
bytes
Users#
- asyncend_typing
- asyncfetch_message
- asyncfetch_profile
- asyncget_id
- asynchistory
- asyncpurge
- asyncsearch
- asyncsend
- defset_masquerade
- asyncstart_typing
- deftyping
- 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
- 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
ofRelationship
- profile#
The user’s profile.
- Type:
UserProfile
- bot#
Whether the user is a bot or not.
- Type:
bool
- 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:
- 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:
- 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.